I can't figure out how to add a progress bar to my Download/Upload manager and I need some help.
I've looked on YouTube and forums and can't figure it out.
I have a button that will allow me to choose the location and then the download process gets sent to a background worker.
Here is my code for the button:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim args() As String = {"", ""}
                Me.SaveFileDialog1.FileName = Me.ListBox2.SelectedItem
                If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
                    args(0) = Me.ListBox1.SelectedItem
                    args(1) = SaveFileDialog1.FileName
                    BackgroundWorker1.RunWorkerAsync(args)
                End If
End Sub
Here is my code for the Background worker (Download Function):
Code:
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        Dim RemoteFileName As String = e.Argument(0).ToString
        Dim LocalFileName As String = e.Argument(1).ToString
        Dim request1 As FtpWebRequest = Nothing
        Dim response1 As FtpWebResponse = Nothing
        request1 = CType(WebRequest.Create("FTPURL" + ListBox2.SelectedItem), FtpWebRequest)
        request1.Credentials = New NetworkCredential("FTPUsername", "FTPPassword")
        request1.Method = Net.WebRequestMethods.Ftp.DownloadFile
        response1 = CType(request1.GetResponse(), FtpWebResponse)
        Using ResponseStream1 As Stream = response1.GetResponseStream()
            Using FileStream As FileStream = File.Create(LocalFileName)
                Dim buff(1024) As Byte
                Dim bytesRead As Integer = 0
                While (True)
                    bytesRead = ResponseStream1.Read(buff, 0, buff.Length)
                    If (bytesRead = 0) Then Exit While
                    FileStream.Write(buff, 0, bytesRead)
                End While
            End Using
        End Using
        e.Result = "Success!" 'This will be passed back to the RunWorkerCompleted event in the e.Result there...
    End Sub
I need help putting in a progress bar for this download process without modifying my current code.
I don't mind adding code as long as I don't have to modify my current code.