我在ftp服務器中有zip文件,這個zip文件包含多個然後一個xml文件,我想下載這個zip文件並保存到本地磁盤,我寫下面的代碼,我下載文件,但是當我嘗試解壓這個壓縮它把我錯誤文件已損壞......如何從FTP服務器下載ZipFile
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(_remoteHost + file);
request.Method = WebRequestMethods.Ftp.DownloadFile;
request.Credentials = new NetworkCredential(_remoteUser, _remotePass);
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
StreamWriter writer = new StreamWriter(destination);
writer.Write(reader.ReadToEnd());
writer.Close();
reader.Close();
response.Close();
你需要告訴我們更多。比如,這是什麼語言? – Almo 2011-12-13 18:59:28
你看過http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.aspx – 2011-12-13 19:04:42