表象上看,好像大文件无法下载。当下载大文件是为0KB。小文件在100KB左右的可以下载。请高手指点。
附上代码
:
1 FileStream outputStream = new FileStream(localfile, FileMode.Create); 2 3 reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP + "/" + remotfile)); 4 reqFTP.Method = WebRequestMethods.Ftp.DownloadFile; 5 6 reqFTP.UseBinary = true; 7 reqFTP.KeepAlive = false; 8 reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword); 9 10 FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse(); 11 12 Stream ftpStream = response.GetResponseStream(); 13 14 long cl = response.ContentLength; 15 16 int bufferSize = 4096; 17 18 int readCount; 19 20 byte[] buffer = new byte[bufferSize]; 21 22 readCount = ftpStream.Read(buffer, 0, bufferSize); 23 24 while (readCount > 0) 25 { 26 outputStream.Write(buffer, 0, readCount); 27 28 readCount = ftpStream.Read(buffer, 0, bufferSize); 29 } 30 31 ftpStream.Close(); 32 33 outputStream.Close(); 34 35 response.Close();
看一下 配置文件的文件大小 设置多少