且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在c#中的服务器上检查文件是否存在

更新时间:2023-11-27 18:45:10

文件类具有静态方法Exists.那应该有帮助.由于您提到的是服务器,因此我假设您想将该信息发送回UI或客户端.

您必须前往服务器才能了解这一点.
File class has a static method Exists. That should help. Since you are mentioning server, I assume you want to sent that information back to UI or the client.

You will have to make a trip to server to get to know this.


看看这种方法

http://***.com/questions/347897/how-to-check-if-file-exists-on-ftp-before-ftpwebrequest [
Have a look at this method

http://***.com/questions/347897/how-to-check-if-file-exists-on-ftp-before-ftpwebrequest[^]


您可以在服务器上尝试Web Service允许托管.

使用[WebMethod] File.Exist("FileNameOnServerLocation")并返回结果.

添加网络参考,您可以从网站或EXE使用它.
You can try Web Service on the server if you allowed to host.

Use a [WebMethod] File.Exist("FileNameOnServerLocation") and return the result.

Add a web reference, you can consume it from website or EXE.