以下代码用于从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
答案 0 :(得分:0)
My.Computer.Network.DownloadFile有一个名为showUI
的参数,您可以将其设置为True以显示操作的进度。
您可以通过以下方式更改代码:
My.Computer.Network.DownloadFile(strFTPpath, strDestPath, "", "", True, 100000, False)
不幸的是,My.Computer.Network.DownloadFile还没有一种异步下载文件的方法,所以如果你想开发自己的用户界面,你必须使用别的东西。