02-15-2013, 01:20 PM
Well in that case you dont need a background worker to display the download progress because WebClient object has it's own set of event handlers just declare the web client under the main class of your project
Example:
[code2=vbnet]Public Class Form1
Dim WithEvents WC As New WebClient[/code2]
Then start the download :
[code2=vbnet]Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
WC.DownloadFileAsync("Address", "FileName")
End Sub[/code2]
Increment the progressbar acording to the download percentage:
[code2=vbnet]Private Sub WC_DownloadProgressChanged(ByVal sender As Object, ByVal e As DownloadProgressChangedEventArgs) Handles WC.DownloadProgressChanged
ProgressBar1.Value = e.ProgressPercentage
End Sub[/code2]
This is the most simple way of downloadng a file and showing progress in a progressbar. You can also use a background worker but that will only complicate things
NOTE : Leave the progressbar at it's default value of 100 because e.ProgressPercentage should be a integer no larger than 100
Example:
[code2=vbnet]Public Class Form1
Dim WithEvents WC As New WebClient[/code2]
Then start the download :
[code2=vbnet]Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
WC.DownloadFileAsync("Address", "FileName")
End Sub[/code2]
Increment the progressbar acording to the download percentage:
[code2=vbnet]Private Sub WC_DownloadProgressChanged(ByVal sender As Object, ByVal e As DownloadProgressChangedEventArgs) Handles WC.DownloadProgressChanged
ProgressBar1.Value = e.ProgressPercentage
End Sub[/code2]
This is the most simple way of downloadng a file and showing progress in a progressbar. You can also use a background worker but that will only complicate things
NOTE : Leave the progressbar at it's default value of 100 because e.ProgressPercentage should be a integer no larger than 100
Sssssssssoftware developer...