private WithEvents myclient as new system.net.webclient
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If My.Computer.Network.IsAvailable = True Then
Dim DownloadAddress As String
DownloadAddress = TextBox2.Text + "\" + System.IO.Path.GetFileName(TextBox1.Text)
MyClient.DownloadFileAsync(New Uri(TextBox1.Text), DownloadAddress)
Else
MsgBox("网络不可用!")
End If
End Sub
Private Sub MyClient_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles MyClient.DownloadFileCompleted
MsgBox("文件下载完成!")
End Sub
Private Sub MyClient_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles MyClient.DownloadProgressChanged