如何在c#中的服务器上检查文件是否存在 [英] how to check if a file exists on a server in c#
本文介绍了如何在c#中的服务器上检查文件是否存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
请帮帮我.我想知道如何检查C#中服务器上是否存在文件.
Hi everyone,
please help me out. I want to know how to check whether a file exists on a server or not in C#.
推荐答案
文件类具有静态方法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://stackoverflow.com/questions/347897/how-to-check-if-file-exists-on-ftp-before-ftpwebrequest [
Have a look at this method
http://stackoverflow.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.
这篇关于如何在c#中的服务器上检查文件是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文