Download with Progressbar

Download something from internet and show progress using progressbar

Public Class Form1

    Private Sub downloadFile(ByVal sourcePath As string, ByVal destinationPath As string)
        Dim wc As New System.Net.WebClient()
        AddHandler wc.DownloadProgressChanged, AddressOf DownloadProgressCallback

        wc.DownloadFileAsync(New System.Uri(sourcePath), destinationPath)

        ' Uncomment this if you want to pause in this sub while the file downloads
        'While wc.IsBusy = True
        '    Application.DoEvents()
        'End While

    End Sub

    Private Sub DownloadProgressCallback(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs)
        ProgressBar1.Maximum = e.TotalBytesToReceive
        ProgressBar1.Value = e.BytesReceived
    End Sub

End Class