嘿我一直在寻找一个解决方案,如果网络连接丢失就抛出网络异常,我将ReadWriteTimeout
放入8秒,但是当我没有抛出异常时拔插头。我将filezilla服务器上的传输超时更改为0。
还有另一种方法可以解决这个问题吗?!非常感谢您提供任何信息。
ftpWebReq.Credentials = credens;
ftpWebReq.Method = WebRequestMethods.Ftp.UploadFile;
ftpWebReq.KeepAlive = false;
ftpWebReq.ServicePoint.ConnectionLimit = 1000;
ftpWebReq.UseBinary = true;
ftpWebReq.Timeout = 30000000;
ftpWebReq.ReadWriteTimeout = 8000;
using(FileStream fs = File.OpenRead(file.FullName))
using (ftpstream = ftpWebReq.GetRequestStream())
{
byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
ftpstream.Write(buffer, 0, buffer.Length);
}