With the following code:
using (var uploadClient = new WebClient()) {
uploadClient.Credentials = new NetworkCredential(util.ftp_user, util.ftp_pass);
uploadClient.UploadProgressChanged = new UploadProgressChangedEventHandler(UploadProgressCallback);
uploadClient.UploadFileCompleted = new UploadFileCompletedEventHandler(UploadProgressCompleted);
uploadClient.UploadFileAsync(new Uri(util.URIstr picName), "POST", filenamewAdress);
}
public void UploadProgressCallback(object sender, UploadProgressChangedEventArgs e) {
Console.WriteLine("UploadProgressCalledback");
}
public void UploadProgressCompleted(object sender, UploadFileCompletedEventArgs e) {
Console.WriteLine("Upload File Completed");
}
The UploadProgressChangedEventHandler is not being called, but UploadFileCompletedEventHandler is being called and the file is being uploaded correctly. What am I missing?
CodePudding user response:
Change
uploadClient.UploadFileAsync(new Uri(util.URIstr picName), "POST", filenamewAdress);
To
uploadClient.UploadFileAsync(new Uri(util.URIstr picName), "STOR", filenamewAdress);
CodePudding user response:
My problem is Solved. I used "STOR" instead of "POST" and now UploadProgressChangedEventHandler is worked correctly.