Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Net
- Public Class From1
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- SaveFileDialog1.Filter = "Arquivos para download|*.jpg|.exe|*.exe|*.rar|.zip|*.zip|"
- SaveFileDialog1.ShowDialog()
- TextBox2.Text = SaveFileDialog1.FileName
- End Sub
- Public WithEvents download As WebClient
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- Try
- download = New WebClient
- download.DownloadFileAsync(New Uri(TextBox1.Text), TextBox2.Text)
- Catch ex As Exception
- MsgBox("Você pode não ter colocado uma url ou caminho válido!" & vbCrLf & "Reveje se a URL ou o caminho está correto", MsgBoxStyle.Critical, "Excesão Ocorrrida!")
- End Try
- End Sub
- Private Sub download_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles download.DownloadFileCompleted
- MessageBox.Show("Download Completado!")
- ProgressBar1.Value = 0
- End Sub
- Private Sub download_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles download.DownloadProgressChanged
- ProgressBar1.Value = e.ProgressPercentage
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement