更新时间:2023-08-21 20:33:28
这是非常混乱的。
http://www.example-code.com/csharp/ftp_dirExists.asp [ ^ ]
似乎使用了一个自定义组件,但你可以在那里看看他们是否这样做。你也可以尝试浏览目录,看看你得到了什么,或创建在任何情况下,如果它不会清空它。
This is pretty messy.
http://www.example-code.com/csharp/ftp_dirExists.asp[^]
seems to use a custom component, but you could look in there to see hwo they do it. You could also just try browsing to the directory, and see what you get back, or creating it in any case, if that doesn't empty it.
一种方法是:使用适当的列出目录System.Net.FtpWebRequest.Met hod
。该方法可以是System.Net.WebRequestMethods.Ftp.ListDirectory
或System.Net.WebRequestMethods.Ftp。 ListDirectoryDetail
。读取HTTP响应System.Net.FtpWebResponse
中的数据,查看哪个目录存在,哪个目录不存在。
请参阅:
http://msdn.microsoft .com / zh-cn / library / system.net.ftpwebrequest.method.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system.net.webrequestmethods.ftp.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system.net .ftpwebresponse.aspx [ ^ ]。-SA
One way is: list directories using appropriateSystem.Net.FtpWebRequest.Method
. The method can beSystem.Net.WebRequestMethods.Ftp.ListDirectory
orSystem.Net.WebRequestMethods.Ftp.ListDirectoryDetail
. Read the data in HTTP responseSystem.Net.FtpWebResponse
to see which directory exists and which is not.
Please see:
http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.method.aspx[^],
http://msdn.microsoft.com/en-us/library/system.net.webrequestmethods.ftp.aspx[^],
http://msdn.microsoft.com/en-us/library/system.net.ftpwebresponse.aspx[^].—SA
大家好,
我通过使用
Hi All,
I've solved this problem by using
request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
实际上我通过使用上面的webrequest方法从FTP服务器获取所有文件和文件夹并将它们添加到列表框中,然后使用 foreach
如果存在则逐个循环检查。
希望你理解。
Actually I am getting all the files and folders from FTP server by using above webrequest method and add them into list box and after that by using foreach
loop check one by one if it exist or not.
Hope you understand.