每次下了4个文件后就出现这个问题,不知道什么原因?我想下载所有文件,代码如下:
foreach (var ftpListItem in ftp.GetListing(path, FtpListOption.Modify | FtpListOption.Size).Where(ftpListItem => string.Equals(Path.GetExtension(ftpListItem.Name), filetype)))
{
string destinationPath = string.Format(@"{0}\{1}", destinationDirectory, ftpListItem.Name);
using (Stream ftpStream = ftp.OpenRead(ftpListItem.FullName))
using (FileStream fileStream = File.Create(destinationPath, (int)ftpStream.Length))
{
var buffer = new byte[200 * 1024];
int count;
while ((count = ftpStream.Read(buffer, 0, buffer.Length)) > 0)
{
fileStream.Write(buffer, 0, count);
}
}
documentname.Add(ftpListItem.Name);
}
using (Stream ftpStream = ftp.OpenRead(ftpListItem.FullName))这句代码 运行几次后就会出现上述问题