Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Help on webClient.DownloadFileCompleted method
I'm currently using webClient.DownloadFileAsync to download a file in my coding.
I had place the coding below to auto trigger a method upon download complete
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
I have problem trying to assign a value to the label in Complete method
lb_show.Text = "Download Completed";
I would hit an error upon reaching that line
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
[NullReferenceException: Object reference not set to an instance of an object.]
youtubeWeb._Default.Completed(Object sender, AsyncCompletedEventArgs e) in C:inetpubwwwrootyoutubeWebyoutubeWebMain.aspx.cs:129
System.Net.WebClient.OnDownloadFileCompleted(AsyncCompletedEventArgs e) +22
System.Net.WebClient.DownloadFileOperationCompleted(Object arg) +48
System.Web.AspNetSynchronizationContext.CallCallbackPossiblyUnderLock(SendOrPostCallback callback, Object state) +73
Appreciate that anyone could suggest any solution