我的軟件設計使用ftp上傳文件到我的服務器我使用ftpwebrequest來完成所有上傳。當上傳一個700mb的文件時,它會上傳大約500mbs然後停止,當上傳較小的文件時,它可以正常工作,較小的文件成功上傳,但它只是想在大文件上正常工作。我有一個後臺工作人員完成上傳,將上傳進度報告給主客戶端上的進度條。當後臺工作完成時,執行後臺工作完成功能。後臺工作者完成功能被執行,但上傳永不完成,進度條停留在65%左右,就像客戶端剛剛停止上傳一樣,並執行後臺工作者完成功能,就像完成上傳一樣。到底發生了什麼錯在這裏上傳未完成和文件劑量不會出現在這裏的服務器上該劑量的上傳上傳大文件使用ftpwebrequest上傳不會完成
void UploadFileInBackground_DoWork(object sender,DoWorkEventArgs e)
{
byte[] data;
int packetsize = 1024 * 8;
string Destination = UploadURI + cattext + "/" + ID + ".obj";
string source = DialogBrower.FileName;
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(Destination);
request.Credentials = new NetworkCredential("user", "pass");
request.Method = WebRequestMethods.Ftp.UploadFile;
request.UsePassive = true;
request.UseBinary = true;
request.KeepAlive = false;
using (FileStream fs = new FileStream(source, FileMode.Open, FileAccess.Read))
{
try
{
long filesize = fs.Length;
long sum = 0;
int count = 0;
data = new byte[packetsize];
Stream reqStream = request.GetRequestStream();
float totalpackits = filesize/packetsize;
float weightofpackit = 100/totalpackits;
float percentage = 0;
while (sum < filesize)
{
List<string> statusparms = new List<string>();
count = fs.Read(data, 0, packetsize);
reqStream.Write(data, 0, count);
sum += count;
percentage += weightofpackit;
int percentagetotal = Convert.ToInt32(Math.Round(percentage));
statusparms.Add(sum.ToString());
statusparms.Add(filesize.ToString());
UploadFileInBackground.ReportProgress(percentagetotal, statusparms);
}
reqStream.Close();
uploadedname = uploadingname;
}
finally
{
fs.Dispose();
data = null;
}
}
}
我編輯了你的標題。請參閱:「[應該在其標題中包含」標籤「](http://meta.stackexchange.com/questions/19190/)」,其中的共識是「不,他們不應該」。 –