遍历远程文件夹下的文件,您可以考虑使用FTP的方式,具体的请参考下述代码:
private string GetFileNames(string URI)
{
WebClient wClient = new WebClient();
FtpWebRequest FtpClient;
Uri uri = new Uri(URI);
FtpClient = (FtpWebRequest)WebRequest.Create(uri);
FtpClient.Credentials.GetCredential(uri, "user").UserName = "zwc";
FtpClient.Credentials.GetCredential(uri, "user").Password = "12345";
FtpClient.Credentials.GetCredential(uri, "user").Domain = "";
FtpClient.Method = WebRequestMethods.Ftp.ListDirectory;
FtpWebResponse response = (FtpWebResponse)FtpClient.GetResponse();
StreamReader stream = new StreamReader(response.GetResponseStream());
return stream.ReadToEnd();
}
遍历远程服务器某个文件夹下的文件,布布扣,bubuko.com
原文地址:http://www.cnblogs.com/dekevin/p/3926630.html