这是用于列出ftp目录中的文件:
FtpWebRequest ftpRequest = (FtpWebRequest)WebRequest.Create(uri);
ftpRequest.Credentials =new NetworkCredential("username","pword");
ftpRequest.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
FtpWebResponse response = (FtpWebResponse)ftpRequest.GetResponse();
StreamReader streamReader = new StreamReader(response.GetResponseStream());
string line = streamReader.ReadLine();
while (!string.IsNullOrEmpty(line))
{
// if file is .txt, read file content
}
但是如何阅读文件的内容?不只是在这里列出?
(我现在首先要下载它们) 感谢。