Forum Post: WebClient events do not fire

  • Thread starter Thread starter ignace.sys@kluwer.be
  • Start date Start date
Status
Not open for further replies.
I

ignace.sys@kluwer.be

Guest
I want to download files. The file download works but the events DownloadProgressChanged and DownloadFileCompleted are not fired. I've rried the code in C#: works perfect. What am i doing wrong ? Thanks, Ignace /*************************************** Code ***************************************/ USING System.Net.*. USING System.*. USING System.ComponentModel.*. CLASS DownloadFile: DEF VAR Client AS WebClient. DEF VAR w-File AS Uri. METHOD PUBLIC VOID StartDownload(INPUT p-File AS CHARACTER,INPUT p-Target AS CHARACTER): Client = NEW WebClient(). w-File = NEW Uri(p-File). Client:DownloadProgressChanged:Subscribe(Client_DownloadProgressChanged). Client:DownloadFileCompleted:Subscribe(Client_DownloadFileCompleted). Client:DownloadFileAsync (w-File, p-Target). END METHOD. METHOD PRIVATE VOID Client_DownloadProgressChanged(sender AS System.Object, e AS DownloadProgressChangedEventArgs ) : MESSAGE e:ProgressPercentage VIEW-AS ALERT-BOX INFO BUTTONS OK. END METHOD. METHOD PUBLIC VOID Client_DownloadFileCompleted(sender AS System.Object, e AS AsyncCompletedEventArgs ) : MESSAGE "Download completed!" VIEW-AS ALERT-BOX INFO BUTTONS OK. END METHOD. END CLASS. /* private void btnDownload_Click(object sender, EventArgs e) { WebClient webClient = new WebClient(); webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed); webClient.DownloadFileAsync(new Uri("http://mysite.com/myfile.txt"), @"c:\myfile.txt"); } private void Completed(object sender, AsyncCompletedEventArgs e) { MessageBox.Show("Download completed!"); } */

Continue reading...
 
Status
Not open for further replies.
Back
Top