[英]how to set progressbar while downloading file from ftp
以下代碼用於從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
這是我要下載的用戶界面 ,我想在其中添加進度條
代碼: VB.NET
My.Computer.Network.DownloadFile有一個名為showUI
的參數,您可以將其設置為True以顯示操作進度 。 您可以通過以下方式更改代碼:
My.Computer.Network.DownloadFile(strFTPpath, strDestPath, "", "", True, 100000, False)
不幸的是,My.Computer.Network.DownloadFile無法異步下載文件,因此,如果要開發自己的UI,則必須使用其他方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.