Get server response using WebClient.UploadFileAsync method

I am using WebClient.UploadFileAsync to upload local files to a web server, and I am wondering if it is possible to receive responses from the server after the download is complete?

When using WebClient.UploadFile you can get an array of bytes containing any response. But I would like to do asynchronous loading.

Thanks.

+6
source share
1 answer

Sign Up for UploadFileCompleted Event

From MSDN:

 client.UploadFileCompleted += new UploadFileCompletedEventHandler (UploadFileCallback); .... private static void UploadFileCallback(Object sender, UploadFileCompletedEventArgs e) { string reply = System.Text.Encoding.UTF8.GetString (e.Result); Console.WriteLine (reply); } 
+12
source

Source: https://habr.com/ru/post/896251/


All Articles