此问题与该问题完全相同: UploadProgressChanged Event Not Being Called
更多详细信息:
void Upload(string url, string filePath)
{
WebClient webClient = new WebClient();
var authorizationHeaderValue = "Bearer: " + token;
webClient.Headers.Add("Authorization", authorizationHeaderValue);
webClient.UploadProgressChanged += new UploadProgressChangedEventHandler(WebClientUploadProgressChanged);
webClient.UploadFileCompleted += WebClientUploadCompleted;
webClient.UploadFileAsync(new System.Uri(url), filePath);
}
void WebClientUploadProgressChanged(object sender, UploadProgressChangedEventArgs e)
{
Debug.Log("Upload {0}% complete. " + e.ProgressPercentage);
}
void WebClientUploadCompleted(object sender, UploadFileCompletedEventArgs e)
{
string reply = System.Text.Encoding.UTF8.GetString(e.Result);
Debug.Log(reply);
}
最初的问题是6年前提出的,至今仍没有解决的办法。有人有解决方法吗?