【发布时间】:2014-04-07 08:42:52
【问题描述】:
以下代码用于从driveHq下载exe文件
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim strFTPpath, strDestPath As String
Cursor.Current = Cursors.WaitCursor
'strFTPpath is the url of where Latest upd is located
'strDestPath is system path to dwonload upd from FTP
strFTPpath = "ftp://MYUSRNAM:MYPWD@ftp.drivehq.com/rstari9kremcos/RStari9.exe"
strDestPath = "D:\Rstari9\GDS\RStari9.exe"
My.Computer.Network.DownloadFile(strFTPpath, strDestPath)
Cursor.Current = Cursors.Arrow
Button1.Enabled = False
MsgBox("latest updation successfully downloaded to 'D:\Rstari9\GDS\RStari9.exe'", MsgBoxStyle.Information, "RStari9 - Download Success")
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Update downloading aborted...")
End Try
End Sub
和this is my UI to download,我想在其中添加一个进度条
代码:VB.NET
【问题讨论】:
-
不要在 UI 线程中执行此操作,否则它会在完成之前停止您的 UI。使用 BackgroundWorker。使用 DownloadFile(),您将不会收到有关下载状态的通知,因此您无法显示进度条(除非您只想要一个选取框)。您可以做的是将 showUi 参数设置为 true。
-
@Adriano 有什么例子吗??
-
试试this,这不是你在做什么,但它会解释技术。