我有:
foreach (FileInfo fileinfo in Arquivos)
{
float zz = (float)fileinfo.Length;
zz = (zz / 1024f) / 1024f;
label8.Text = "sending: " + fileinfo.Name + "("+zz.ToString("0.0")+"MB)...";
label8.Update();
WebClient client = new System.Net.WebClient();
client.Credentials = new System.Net.NetworkCredential(usuario, senha);
client.UploadProgressChanged += new UploadProgressChangedEventHandler(UploadProgressCallback);
client.UploadFile(new Uri("ftp://" + ftp + "/" + caminho + "//" + fileinfo.Name), "STOR", pasta + mes + fileinfo.Name);
bar++;
backgroundWorker1.ReportProgress(bar);
}
我需要创建一个 UploadProgressChanged,所以我有:
client.UploadProgressChanged += new UploadProgressChangedEventHandler(UploadProgressCallback);
和
private void UploadProgressCallback(object sender, UploadProgressChangedEventArgs e)
{
progressBar2.Value = e.ProgressPercentage;
progressBar2.Update();
}
UploadProgressChanged 不适用于 UploadFile,只是 UploadfileAsync,但我每次需要发送 1 个文件。如何将 UploadFile 更改为 UploadFileAsync 并每次发送一个文件?