Usuário com melhor resposta
Problema com WebCliente - DownloadProgressChanged

Pergunta
-
Estou tentando obter a porcentagem do download de um arquivo vindo do filezilla ftp
Dim WithEvents DownloadFTP As New Net.WebClient ' Novo WebCliente Dim Downloadpath As New Uri("ftp://localhost/BK5.iso") Private Sub DownloadFile() DownloadFTP.Credentials = New Net.NetworkCredential("root", "root") DownloadFTP.DownloadFileAsync(Downloadpath, "T: \Documentos\BK5.iso") End Sub 'Rotina para iniciar Download Private Sub DownloadFTP_DownloadProgressChanged(sender As Object, e As DownloadProgressChangedEventArgs) Handles DownloadFTP.DownloadProgressChanged ProgressBar1.Value = e.ProgressPercentage.ToString End Sub 'Informa porncentagem do Download
Mas a progressbar so muda o valor depois que o download termina.... ouvi dizer que tem que ser no modo passivo como false, mais não sei alterar isso no webcliente...
Respostas
-
Boa boite, Tente fazer assim
Dim wc As New System.Net.WebClient() Dim cr As New NetworkCredential("root", "root") wc.Credentials = cr Dim uri As New Uri("ftp://localhost/BK5.iso") wc.DownloadFileAsync(uri, "caminho") AddHandler wc.DownloadProgressChanged, AddressOf Me.DownloadProgressChangedCallback AddHandler wc.DownloadFileCompleted, AddressOf Me.DownloadFileCompletedCallback End Sub Private Sub DownloadProgressChangedCallback(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) ProgressBar1.Value = e.ProgressPercentage End Sub Private Sub DownloadFileCompletedCallback(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) End Sub
ou tente fazer o download sem o ftp
ftp.localhost/BK5.iso
http://localhost/BK5.iso
- Marcado como Resposta Cristopher C I_ terça-feira, 7 de julho de 2015 19:03
Todas as Respostas
-
Boa boite, Tente fazer assim
Dim wc As New System.Net.WebClient() Dim cr As New NetworkCredential("root", "root") wc.Credentials = cr Dim uri As New Uri("ftp://localhost/BK5.iso") wc.DownloadFileAsync(uri, "caminho") AddHandler wc.DownloadProgressChanged, AddressOf Me.DownloadProgressChangedCallback AddHandler wc.DownloadFileCompleted, AddressOf Me.DownloadFileCompletedCallback End Sub Private Sub DownloadProgressChangedCallback(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) ProgressBar1.Value = e.ProgressPercentage End Sub Private Sub DownloadFileCompletedCallback(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) End Sub
ou tente fazer o download sem o ftp
ftp.localhost/BK5.iso
http://localhost/BK5.iso
- Marcado como Resposta Cristopher C I_ terça-feira, 7 de julho de 2015 19:03
-
-