Download a file from url

  • Thread starter Thread starter Malainho
  • Start date Start date
M

Malainho

Guest
Hello People,

Please, help me to solve this problem.

I try download a file from a url, but not work.

The variable arquivo have the url correct to download.
The variable destino have the folder in my cumputer to save the file.

The imports

Imports System.ComponentModel
Imports System.IO
Imports System.Text
Imports System.Web.Script.Serialization
Imports System.Net.Http
Imports System.Net
Imports System.IO.Compression
Imports System.Windows.Threading
Imports System.Threading

The code:

Dim client As WebClient = New WebClient()
AddHandler client.DownloadProgressChanged, AddressOf DownloadProgressChanged
AddHandler client.DownloadFileCompleted, AddressOf DownloadFileCompleted
client.DownloadFileAsync(New Uri(arquivo), destino)


The Methods:

Public Sub DownloadProgressChanged(sender As Object, e As System.Net.DownloadProgressChangedEventArgs)
prbProgresso.Value = e.ProgressPercentage
End Sub

Public Sub DownloadFileCompleted(sender As Object, e As EventArgs)
' Reinicia o ProgressBar
prbProgresso.Value = 0
prbProgresso.IsIndeterminate = True

' Info: A descompactar as atualizações
lblInfo.Content = "A descompactar as atualizações"
txtMensagem.Text = "A descompactar as atualizações"

End Sub

I add reference to:

System.Net.Http
System.Net.Extensions

How i solve this problem ?

Thank you

Continue reading...
 
Back
Top