FtpWebResponse的GetResponse()响应时间非常长
摘抄了部分代码,但是如果下载包比较大时,发现GetResponse();响应的时间特别长,不知道哪位大侠能指点一下,谢谢!
FileStream outputStream = new FileStream("d:" + "\\" + "0.rar", FileMode.Create);
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + "192.168.3.201" + "/" + "0.rar"));
reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;
reqFTP.UseBinary = true;
reqFTP.Credentials = new NetworkCredential("zte", "zte");
FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
//ftpHoldTime = new System.Threading.Timer(DisconnectFtp, ipaddress, 0, Convert.ToInt32(((eventpointMessage)ob).FtpHoldTime));
Stream ftpStream = response.GetResponseStream();
long cl = response.ContentLength;
int bufferSize = 2048;
int readCount;
byte[] buffer = new byte[bufferSize];
readCount = ftpStream.Read(buffer, 0, bufferSize);
while (readCount > 0)
{
outputStream.Write(buffer, 0, readCount);
readCount = ftpStream.Read(buffer, 0, bufferSize);
}
//Channel4_2.listView3.Items[FtpNo - 1].SubItems[2].Text = "成功";
ftpStream.Close();
outputStream.Close();
response.Close();