我不得不从FTP服务器下载子目录中所有文件名的文件。可以提供任何帮助。下面的代码是逐行读取的 [英] I had to download all the files with file names in subdirectory from FTP server.Can any one help. The below code is reading line by line

查看:64
本文介绍了我不得不从FTP服务器下载子目录中所有文件名的文件。可以提供任何帮助。下面的代码是逐行读取的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

// Create a FTPCredentials
FtpWebRequest ftpRequest = (FtpWebRequest)WebRequest.Create(strFTPServer + "/" + strRemoteDirectory + "/");
ftpRequest.Credentials = new NetworkCredential(strFTPUser, strFTPPassword);
ftpRequest.Method = WebRequestMethods.Ftp.ListDirectory;


// Associate the new Uri object to the myProxy object.
WebProxy myProxy = new WebProxy();                 
Uri newUri = new Uri(strProxyAddress);               
myProxy.Address = newUri;


// Create a NetworkCredential object.
myProxy.Credentials = new NetworkCredential(strUserName, strPassword);
ftpRequest.Proxy = myProxy;


//DownLoad  file
ftpRequest.Method = WebRequestMethods.Ftp.DownloadFile;
FtpWebResponse response = (FtpWebResponse)ftpRequest.GetResponse();
StreamReader streamReader = new StreamReader(response.GetResponseStream());


MemoryStream memStream = new MemoryStream();
List<string> directories = new List<string>();


string line = streamReader.ReadLine();
while (!string.IsNullOrEmpty(line))
{
    directories.Add(line);
    line = streamReader.ReadLine();
}

推荐答案

你好



点击以下链接< br $> b $ b

FTP客户端.NET 2.0的库 [ ^ ]





https://go4answers.webhost4life.com/Example/downloading-files-directory-ftp-csharp-11808.aspx [ ^ ]


这篇关于我不得不从FTP服务器下载子目录中所有文件名的文件。可以提供任何帮助。下面的代码是逐行读取的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆