Private Sub DownLoadFiles() myWebClient = New WebClient AddHandler myWebClient.DownloadProgressChanged, AddressOf ShowDownProgress 这一句是在网上看到的,用这句来捕获下载进度变化事件,不知道对不对。 myWebClient.DownloadFile("http://mir3.clientdown.sdo.com/Mir3/Full_Mir3_Setup_V1.0.0.22.exe", "Full_Mir3_Setup_V1.0.0.22.exe") End Sub
DownLoadFiles 方法是通过线程启动的,如下: Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click downThread = New Thread(AddressOf DownLoadFiles) downThread.Start() End Sub
'这里是进度条显示 Private Sub ShowDownProgress(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) ProgressBar1.Value = e.ProgressPercentage End Sub