Advertisement
Guest User

Untitled

a guest
May 29th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. Imports System.Net
  2.  
  3. Public Class From1
  4.  
  5. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  6. SaveFileDialog1.Filter = "Arquivos para download|*.jpg|.exe|*.exe|*.rar|.zip|*.zip|"
  7. SaveFileDialog1.ShowDialog()
  8. TextBox2.Text = SaveFileDialog1.FileName
  9. End Sub
  10.  
  11. Public WithEvents download As WebClient
  12.  
  13. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  14. Try
  15. download = New WebClient
  16. download.DownloadFileAsync(New Uri(TextBox1.Text), TextBox2.Text)
  17. Catch ex As Exception
  18. 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!")
  19. End Try
  20. End Sub
  21.  
  22. Private Sub download_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles download.DownloadFileCompleted
  23. MessageBox.Show("Download Completado!")
  24. ProgressBar1.Value = 0
  25. End Sub
  26.  
  27. Private Sub download_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles download.DownloadProgressChanged
  28. ProgressBar1.Value = e.ProgressPercentage
  29. End Sub
  30.  
  31. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement