当我添加新文件时,我的程序每周从FTP服务器下载一次文件。由于上传时间周围的所有流量,服务器很慢,这会降低下载到程序崩溃的程度。该文件大约2.5-3 GB,一些人一次下载,下载可能需要2-3小时。我的问题是,当我的程序崩溃时,我必须重新开始。有没有我可以修改我当前的代码,以便在多个部分中拆分下载,然后再将它们组合起来。最终我想要的是一个3线程下载,1个从0 gb,1 gb和2 gb开始下载,同时全部3个下载,然后在完成后将它们组合起来。希望你能指导我做正确的事情!
Public Event DownloadProgressChanged As DownloadProgressChangedEventHandler
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'Download AddHandler
wc = New WebClient()
AddHandler wc.DownloadProgressChanged, Sub(s As Object, ByVal e1 As DownloadProgressChangedEventArgs)
Me.Invoke(New MethodInvoker(Sub() StatusToolStripMenuItem.Text = "Status: Downloading (" & Math.Round(e1.BytesReceived / e1.TotalBytesToReceive * 100, 2).ToString("0.00") & " %)"))
lastUpdate = Now
If e1.ProgressPercentage = 100 Then downloaded = True
End Sub
End sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
wc.DownloadFileAsync(New Uri("ftp://user:password@ip/ESStatistikListeModtag/" & XML), downloadPath & XML)
End Sub