简体   繁体   中英

How searching files on the client-side from a webservice placed on the server?

I have a webservice. The webservice is calling from the Server side. And when the service looking to the c-drive, he's looking in the Server area. When you expected that the c-drive is on the client-side.

 if (!File.Exists(filename)) // filename = "C:\\temp\MyFile.pdf"; must by on the client-side. But it looks on the server-side.
     throw new FileNotFoundException(String.Format("File not found: '{0}'!", filename));

I want to see "C:\\temp\\MyFile.pdf" on the client-side and "\\\\MyServer\\c$\\temp\\MyFile.pdf" on the server-side.

What do I have to do?

Try following code,

FileInfo fi = new FileInfo(@"\\MyServer\share\MyFile.pdf");
bool exists = fi.Exists;

Note: You have to transform your file path to above format.

Updated with the conversion part,

string fileName = Path.GetFileName(@"c:\share\MyFile.pdf");
string clientPath= @"\\MyServer\share\";
FileInfo fi = new FileInfo(Path.Combine(clientPath,fileName));
bool exists = fi.Exists;

can't do.

you can try redesign your app/system, that the webservice/server will expecting the pdf to be uploaded as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM