服务器绝对路径问题 [英] Problem with server absolute paths

查看:213
本文介绍了服务器绝对路径问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.

问题如下:

我在Web服务器(ws01)中有一个Web服务,该服务从客户端获取绝对路径.客户端位于网络内部的一台计算机中,并提供Web服务的绝对路径.路径中的文件始终位于另一台服务器(FS04)上.并使用如下所示的openfile对话框给出:

Hi all.

The problem is as follows:

I have a web service in a web server(ws01) that takes an absolute path from the client. The client is located in a machine inside the network and gives the absolute path to the webservice. The file from the path is always on another server(FS04). And is given using a openfile dialog like so:

reference = new fileProcessorRef.Service1SoapClient();

OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "c:\\" ;
openFileDialog1.Filter = "Image files (*.*)|*.*" ;
openFileDialog1.FilterIndex = 2 ;
openFileDialog1.RestoreDirectory = true ;
openFileDialog1.Multiselect=true;

DialogResult result = openFileDialog1.ShowDialog();

foreach (string file in openFileDialog1.FileNames)
{
   //Call web service
   processorResult = reference.ProcessFile(file);
}



路径(根据debug)是这样的:
"\\\\ Fs04 \\ files $ \\ file.tif"

客户端中该路径上的File.Exists()会按预期返回true.
问题是在Web服务器中运行相同的路径时返回false.

这不是网络错误,因为客户端和wb服务器都可以访问该文件.我对两个都使用run命令进行了测试:

"\\ Fs04 \\ files $ \\ file.tif"

我不知道问题出在哪里,我怀疑路径前面是\\\\而不是\\.当我在开发计算机中使用localhost时,它的工作情况就很好,而将应用程序部署到Web服务器后,它就停止了工作.

任何见识将不胜感激.



The path(according to the debug )is like this:
"\\\\Fs04\\files$\\file.tif"

File.Exists() on that path in the client it returns true as expected.
The problem is running the same path in the web server returns false.

It is not a network error as both client and wb server have access to the file. I tested using the run command on both like so:

"\\Fs04\\files$\\file.tif"

I don''t know what the problem is, I suspected the \\\\ instead of \\ in front of the path. It worked just fine when I was using localhost in my development machine and as soon as I deployed the app to the web server it stopped working.

Any insights would be appreciated.

推荐答案

\\ file.tif"

客户端中该路径上的File.Exists()会按预期返回true.
问题是在Web服务器中运行相同的路径时返回false.

这不是网络错误,因为客户端和wb服务器都可以访问该文件.我对两个都使用run命令进行了测试:

"\\ Fs04 \\ files
\\file.tif"

File.Exists() on that path in the client it returns true as expected.
The problem is running the same path in the web server returns false.

It is not a network error as both client and wb server have access to the file. I tested using the run command on both like so:

"\\Fs04\\files


\\ file.tif"

我不知道问题出在哪里,我怀疑路径前面是\\\\而不是\\.当我在开发计算机中使用localhost时,它运行良好,并且将应用程序部署到Web服务器后,它就停止了工作.

任何见识将不胜感激.
\\file.tif"

I don''t know what the problem is, I suspected the \\\\ instead of \\ in front of the path. It worked just fine when I was using localhost in my development machine and as soon as I deployed the app to the web server it stopped working.

Any insights would be appreciated.




我不确定它是否对您有帮助,但是无论如何,您都可以尝试通过以下方式使用InitialDirectory:

Hi,

I''m not sure it will help u but anyway u could try using InitialDirectory in such way:

openFileDialog1.InitialDirectory = @"C:\";



几年前它帮助我解决了类似的问题...

问候



It helped me in similar problem years ago...

Regards,


这篇关于服务器绝对路径问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆