Private WithEvents myFtpUploadWebClient As New WebClient 'here you track what happened when upload completes Private Sub myFtpUploadWebClient_UploadFileCompleted(ByVal sender As Object, ByVal e As System.Net.UploadFileCompletedEventArgs) Handles myFtpUploadWebClient.UploadFileCompleted 'If we didn't succeed, we want to know what went wrong If e.Error IsNot Nothing Then MessageBox.Show(e.Error.Message) Else MessageBox.Show("File upload complete!") End If End Sub 'and here we listen to WebClient's event when UL progress changes Private Sub myFtpUploadWebClient_UploadProgressChanged(ByVal sender As Object, ByVal e As System.Net.UploadProgressChangedEventArgs) Handles myFtpUploadWebClient.UploadProgressChanged MbProgressBar1.Value = e.ProgressPercentage End Sub Private Sub SelectFileButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectFileButton.Click 'ofd is OpenFileDialog OpenFileDialog1.ShowDialog() OpenFileDialog1.Title = "Chose a File" 'Before you connect, and try to upload something to FTP, you must set everything up: 'txtUploadTo, txtLoginUserName and txtLoginPassword are TextBox components 'Uri has to have first argument as full path with file name and file extension (like .html or something). 2nd parameter is pure file name, without the path Dim myUri As New Uri("ftp://testing.vacau.com/public_html/" & OpenFileDialog1.SafeFileName) myFtpUploadWebClient.Credentials = New System.Net.NetworkCredential("Usrname", "Pass") 'Now you do the uploading myFtpUploadWebClient.UploadFileAsync(myUri, OpenFileDialog1.FileName) End Sub
Here as you can see when you click the button a single file automatically starts uploading.
But is there a way of letting the user select multiple files which are then added to a listview and then for the code to keep checking and upload all the files?