我有一個Windows窗體應用程序,其中我使用後臺工作器來上傳文件。在成功上傳209
文件後,它給出了只有7.8kb大小的文件的錯誤While Processing Img1.jpg Unable to write data to the transport connection. An existing connection was forcibly closed by the remote host
。Ftp Upload給出異常無法將數據寫入傳輸連接。一個現有的連接被遠程主機強行關閉了
string uri1;
ftpInfoUpload = LoadHostedSiteData(hs);
ftpInfoUpload[5] = imgRow["Filename"].ToString();
uri1 = String.Format("ftp://{0}/{1}/images/{2}", ftpInfoUpload[1], ftpInfoUpload[2], ftpInfoUpload[5]);
requestUpload = (FtpWebRequest)WebRequest.Create(uri1);
requestUpload.UsePassive = false;
requestUpload.UseBinary = true;
requestUpload.Method = WebRequestMethods.Ftp.UploadFile;
requestUpload.Credentials = new NetworkCredential(ftpInfoUpload[3], ftpInfoUpload[4]);
requestUpload.ContentLength = memStream.Length;
byte[] buff = new byte[bufferSize];
int contentLen;
// Stream to which the file to be upload is written
Stream strm = requestUpload.GetRequestStream();
memStream.Seek(0, SeekOrigin.Begin);
contentLen = memStream.Read(buff, 0, bufferSize);
// Till Stream content ends
while (contentLen > 0)
{
// Write Content from the file stream to the FTP Upload Stream
strm.Write(buff, 0, contentLen);
contentLen = memStream.Read(buff, 0, bufferSize);
}
//Close the file stream and the Request Stream
strm.Close();
strm.Dispose();
ftpStream.Close();
memStream.Close();
//responseUpload.Close();
responseDownload.Close();
想法發生了什麼?
您可能超過了FTP服務器上的配額,因此中止了連接。聯繫服務器管理員以獲得支持。 – 2012-01-06 17:06:05
@HansPassant配額文件數量?服務器有一個用戶可以傳輸的文件數量的配額? – PUG 2012-01-06 17:15:31
可能不是。相反,你所造成的交通總量的配額(取決於你上傳的文件的大小)或者只是一個簡單的連接重置 – yas4891 2012-01-06 18:18:55