Results 1 to 3 of 3

Thread: WebClient Download with Progress Bar?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2009
    Posts
    435

    WebClient Download with Progress Bar?

    How would I make the Progress Bars Value = The Percentage of a file being downloaded using a Webclient?

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: WebClient Download with Progress Bar?

    It would look something like this:

    Code:
        Dim WithEvents wc As New WebClient
        Private Sub wc_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles wc.DownloadProgressChanged
            ProgressBar1.Value = e.ProgressPercentage
        End Sub
    
        Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
            wc.DownloadFile("http://server/somefile.dat", "C:\Temp\download.dat")
        End Sub

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: WebClient Download with Progress Bar?

    The WebClient.DownloadProgressChanged event is raised for asynchronous methods only, e.g. DownloadFileAsync.

    The easiest way to do this is to use My.Computer.Network.DownloadFile. It will display its own modeless dialogue with a Cancel button. If you prefer to display progress in your own form then WebClient.DownloadFileAsync would be the way to go.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

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



Click Here to Expand Forum to Full Width