avant de démarrer ton thread il te faut récupérer la taille du fichier a télécharger, puis juste après avoir démarrer le thread tu lance un timer (maxvalue a 100) ou tu récupere la taille du fichier (local) , puis tu fait un produit en croix
( taille du fichier local x 100 ) / taille du fichier ftp et le resultat obtenu donne la valeur de la progressbar.
Imports System.Threading
Imports System.Net
Public Class Form1
Dim tailleFichftp
Dim fichlocal
Dim fichftp
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim user = ""
Dim pass = ""
fichlocal = "" 'Liens du fichier local
fichftp = "" 'lien du fichier ftp
Try
Dim request As FtpWebRequest = DirectCast(WebRequest.Create(fichftp), FtpWebRequest)
request.Method = WebRequestMethods.Ftp.GetFileSize
request.Credentials = New NetworkCredential(user, pass)
Dim response As FtpWebResponse = DirectCast(request.GetResponse(), FtpWebResponse)
tailleFichftp = response.ContentLength
Catch ex As Exception
End Try
Dim dl As New Thread(New ThreadStart(Sub() download(fichftp, fichlocal, user, pass)))
dl.Start()
Timer1.Start()
End Sub
Private Sub download(ByVal fichftp As String, ByVal fichlocal As String, ByVal user As String, ByVal pass As String)
Try
My.Computer.Network.DownloadFile(fichftp, fichlocal, user, pass)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Dim info As New System.IO.FileInfo(fichlocal)
Dim tailleFichlocal As Long = info.Length
Dim progress = (tailleFichlocal * 100) / tailleFichftp
ProgressBar1.Value = progress
If ProgressBar1.Value = 100 Then
Timer1.Stop()
ProgressBar1.Value = 0
End If
End Sub
End Class