Uploading a file over HTTP and reading the result in C#
Question
The title of this question should be self explanatory, but basically I have this code (working)
progfrm = new progressform();
System.Net.WebClient ahwebclient = new System.Net.WebClient();
progfrm.Show();
ahwebclient.UploadProgressChanged += new System.Net.UploadProgressChangedEventHandler(ahwebclient_UploadProgressChanged);
ahwebclient.UploadFileCompleted += new System.Net.UploadFileCompletedEventHandler(ahwebclient_UploadFileCompleted);
ahwebclient.UploadFileAsync(new Uri("http://upload.anyhub.net/bin/demovu_upload.php"), "C:/install.exe");
while (ahwebclient.IsBusy)
{
Application.DoEvents();
}
How would I read this result of this request once it is completed?
Solution
You get it from the Result property of UploadFileCompletedEventArgs (http://msdn.microsoft.com/en-us/library/system.net.uploadfilecompletedeventargs_members(VS.80).aspx). You already have a UploadFileCompletedEventHandler, so you just need to modify the method implementing that delegate,
OTHER TIPS
This link is help full File upload with progress in C#
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow