Imports System.Net
Public Class Form1
Private WithEvents myWebclient As WebClient
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
myWebclient.CancelAsync() '中断下载
End Sub
Private Sub myWebclient_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles myWebclient.DownloadFileCompleted
MsgBox("下载完毕 ")
End Sub
Private Sub myWebclient_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles myWebclient.DownloadProgressChanged
Me.Label1.Text = CStr(e.UserState) & " downloaded " & e.BytesReceived & " of " & e.TotalBytesToReceive & " bytes. " & e.ProgressPercentage & " % complete... "
End Sub
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim remoteUri As String = "http://j.union.ijinshan.com/jump.php?u_key=6453"
Dim fileName As String = "C:\xx.rar"
myWebclient = New WebClient()
myWebclient.DownloadFileAsync(New Uri(remoteUri), fileName)
End Sub
End Class
点评
引用通告地址 (0):
http://www.cnng.net/blog/trackback.asp?tbID=94
http://www.cnng.net/blog/trackback.asp?tbID=94&CP=GBK
http://www.cnng.net/blog/trackback.asp?tbID=94
http://www.cnng.net/blog/trackback.asp?tbID=94&CP=GBK