C# 做FTP上传时,怎么判断 FTP上 文件路径 是否存在?
7 回答
慕尼黑5688855
TA贡献1848条经验 获得超2个赞
1 private bool DirectoryExist(string URI)
2 {
3 FtpWebRequest reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(URI));
4 reqFTP.Credentials = new NetworkCredential("", "");
5 reqFTP.Method = WebRequestMethods.Ftp.PrintWorkingDirectory;
6
7 reqFTP.UseBinary = true;
8 try
9 {
10 FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
11 response.Close();
12 return true;
13 }
14 catch(Exception ex)
15 {
16 string e=ex.Message;
17 return false;
18 }
19 }
- 7 回答
- 0 关注
- 1294 浏览
添加回答
举报
0/150
提交
取消