3
我使用下面的代碼從遠程FTP服務器下載文件:的FtpWebRequest下載文件大小不正確
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(serverPath);
request.KeepAlive = true;
request.UsePassive = true;
request.UseBinary = true;
request.Method = WebRequestMethods.Ftp.DownloadFile;
request.Credentials = new NetworkCredential(userName, password);
using (FtpWebResponse response = (FtpWebResponse)request.GetResponse())
using (Stream responseStream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(responseStream))
using (StreamWriter destination = new StreamWriter(destinationFile))
{
destination.Write(reader.ReadToEnd());
destination.Flush();
}
我是下載一個DLL,我的問題是,它是作爲文件通過這個過程以某種方式改變。我知道這是因爲文件的大小在增加。我有一個懷疑,這部分的代碼是在過錯:
destination.Write(reader.ReadToEnd());
destination.Flush();
任何人都可以提供任何想法,以什麼可能是錯的?