B
Broggy69
Guest
Files are now downloading one at a time, but the progress bar isn't updating as needed. Small files it updates after file has downloaded.
Large files it doesn't update at all.
Here is my code:
Imports System.Net
Imports System.ComponentModel
Public Class Form1
Dim WithEvents WClient As New WebClient
Public Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim ftpsite As String = "ftp://mysite.com/"
'*** For Third Party Files ***
Dim DB_3rd_FTPFiles() As String = {"File1.zip",
"File2.exe",
File3.zip",
File4.zip"}
For Each ThirdFTP As String In DB_3rd_FTPFiles
If ThirdFTP = "File2.zip" Then
WClient.Credentials = New NetworkCredential("user", "Password")
Dim Downloadpath2 As New Uri(ftpsite & "Folder2/" & ThirdFTP)
AddHandler _WClient.DownloadProgressChanged, AddressOf WClient_ProgressChanged
AddHandler _WClient.DownloadFileCompleted, AddressOf WC_DownloadComplete
WClient.DownloadFile(Downloadpath2, "C:\FakeEDrive\Install\3rdParty\" & ThirdFTP)
WClient.Dispose()
else
WClient.Credentials = New NetworkCredential("user", "password")
Dim Downloadpath As New Uri(ftpsite & ThirdFTP)
AddHandler WClient.DownloadProgressChanged, AddressOf WClient_ProgressChanged
AddHandler WClient.DownloadFileCompleted, AddressOf WC_DownloadComplete
WClient.DownloadFile(Downloadpath, "C:\FakeEDrive\Install\3rdParty\" & ThirdFTP)
WClient.Dispose()
End If
Next
End Sub
Public Sub WC_DownloadComplete(sender As Object, e As AsyncCompletedEventArgs)
Using webClient As New Net.WebClient
RemoveHandler webClient.DownloadFileCompleted, AddressOf WC_DownloadComplete
End Using
End Sub
Private Sub WClient_ProgressChanged(ByVal sender As Object, ByVal e As DownloadProgressChangedEventArgs) Handles WClient.DownloadProgressChanged
ProgressBar1.Value = e.ProgressPercentage
End Sub
End Class
Continue reading...
Large files it doesn't update at all.
Here is my code:
Imports System.Net
Imports System.ComponentModel
Public Class Form1
Dim WithEvents WClient As New WebClient
Public Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim ftpsite As String = "ftp://mysite.com/"
'*** For Third Party Files ***
Dim DB_3rd_FTPFiles() As String = {"File1.zip",
"File2.exe",
File3.zip",
File4.zip"}
For Each ThirdFTP As String In DB_3rd_FTPFiles
If ThirdFTP = "File2.zip" Then
WClient.Credentials = New NetworkCredential("user", "Password")
Dim Downloadpath2 As New Uri(ftpsite & "Folder2/" & ThirdFTP)
AddHandler _WClient.DownloadProgressChanged, AddressOf WClient_ProgressChanged
AddHandler _WClient.DownloadFileCompleted, AddressOf WC_DownloadComplete
WClient.DownloadFile(Downloadpath2, "C:\FakeEDrive\Install\3rdParty\" & ThirdFTP)
WClient.Dispose()
else
WClient.Credentials = New NetworkCredential("user", "password")
Dim Downloadpath As New Uri(ftpsite & ThirdFTP)
AddHandler WClient.DownloadProgressChanged, AddressOf WClient_ProgressChanged
AddHandler WClient.DownloadFileCompleted, AddressOf WC_DownloadComplete
WClient.DownloadFile(Downloadpath, "C:\FakeEDrive\Install\3rdParty\" & ThirdFTP)
WClient.Dispose()
End If
Next
End Sub
Public Sub WC_DownloadComplete(sender As Object, e As AsyncCompletedEventArgs)
Using webClient As New Net.WebClient
RemoveHandler webClient.DownloadFileCompleted, AddressOf WC_DownloadComplete
End Using
End Sub
Private Sub WClient_ProgressChanged(ByVal sender As Object, ByVal e As DownloadProgressChangedEventArgs) Handles WClient.DownloadProgressChanged
ProgressBar1.Value = e.ProgressPercentage
End Sub
End Class
Continue reading...