PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
VS 2010 [RESOLVED] WebClient DownloadFileCompleted Event Not Firing-VBForums
Results 1 to 2 of 2

Thread: [RESOLVED] WebClient DownloadFileCompleted Event Not Firing

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,121

    Resolved [RESOLVED] WebClient DownloadFileCompleted Event Not Firing

    Hi
    I am trying to Download a file using the WebClient. I have added the DownloadProgessChanged And DownloadFileCompleted handles to the webclient.

    The DownloadprogressChanged is firing, but not DownloadFileCompleted.
    Below is my Code.. Plz Help

    vb Code:
    1. Public Class Form1
    2.     Private AppPath As String = Application.StartupPath
    3.     Private WithEvents wc As New WebClient
    4.    
    5.  Private Sub ChkUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChkUpdate.Click
    6.         Try
    7.            
    8.             wc.DownloadDataAsync(New Uri(Me.txtSource.text), "D:\Newexe.exe")
    9.  
    10.        Catch ex As Exception
    11.             MessageBox.Show(ex.Message, "Cloth Store", MessageBoxButtons.OK, MessageBoxIcon.Error)
    12.         End Try
    13.     End Sub
    14.  
    15.     Private Sub DownloadCompleted(ByVal sender As Object, ByVal e As AsyncCompletedEventArgs) Handles wc.DownloadFileCompleted
    16.         Me.LblStatus.Text = "Download Complete"
    17.     End Sub
    18.  
    19.     Private Sub DownloadProgessChanged(ByVal Sender As Object, ByVal e As DownloadProgressChangedEventArgs) Handles wc.DownloadProgressChanged
    20.         Me.LblDownloadedData.Text = e.BytesReceived.ToString
    21.         Me.LblTotalData.Text = e.TotalBytesToReceive.ToString
    22.         Me.ProgressBar1.Value = e.ProgressPercentage
    23.     End Sub

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,121

    Re: WebClient DownloadFileCompleted Event Not Firing

    Got the mistake

    I was using 'DownloadDataAsync" instead of "DownloadFileAsyn"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width