OK I can upload a single specified file but need to create a loop to read and upload all files in a certain folder. Here is code for single file.

'upload a file
        ftp.Upload("c:\test\ftp\upload.exe", "/pub/upload.exe")

Here's my guess on the easiest way to do it, just looping through each item in the folder. You can change the parameters of GetFiles to include subdirectories, or filter the files.

Dim ofd As FolderBrowserDialog
Dim filelist() As String
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
   filelist = System.IO.Directory.GetFiles(ofd.SelectedPath, "*", IO.SearchOption.AllDirectories)
For Each item in filelist
    ftp.Upload(item, "/pub/" & item.Substring(item.LastIndexOf("\")))
Next

End If

Thanks, I think that is getting me close but I get a Null exception on the ofd citing it's being used before actually populated.

Thanks again cellus205, I modified it thus and it works now.

Dim filelist() As String = Directory.GetFiles("C:\test\")

        For Each item In filelist
            ftp.Upload(item, "upload" & item.Substring(item.LastIndexOf("\")))
        Next

Cool, glad it works. You can do it this way if you want, to avoid that error

Using ofd As New FolderBrowserDialog
Dim filelist() As String
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
filelist = System.IO.Directory.GetFiles(ofd.SelectedPath, "*", IO.SearchOption.AllDirectories)
For Each item in filelist
ftp.Upload(item, "/pub/" & item.Substring(item.LastIndexOf("\")))
Next
End If
End Using

Thanks again. Once last question is it possible to have a small popup window with a progress indicator to show something is happening? The only bad part is when it's uploading you can't tell and all you can do it wait and see if the Upload Complete msgbox appears. I mean the msgbox works fine but a progress bar would be better.

The closest I have gotten so far is this code. The progress bar works but populates for each file and I'd like just an overall progress and in it's own msgbox or mini window.

'Set the total number of steps to 100 (or 100%)
            ProgressBar1.Maximum = 100
            'Set the initial value of the progress bar to 0% completed
            ProgressBar1.Value = 0
            'If your progress bar is already visible you don't need this. But this is one of those objects I like to hide when I'm not using it
            ProgressBar1.Visible = True
            'This next line tells your application to wait or go to sleep for 1000ms / 1 second
            System.Threading.Thread.Sleep(1000)
            'Update the progress bar to 15% completed
            ProgressBar1.Value = 15
            'Wait for another second
            System.Threading.Thread.Sleep(1000)
            'Update to 30% complete
            ProgressBar1.Value = 30
            System.Threading.Thread.Sleep(1000)
            ProgressBar1.Value = 45
            System.Threading.Thread.Sleep(1000)
            ProgressBar1.Value = 60
            System.Threading.Thread.Sleep(1000)
            ProgressBar1.Value = 75
            System.Threading.Thread.Sleep(1000)
            ProgressBar1.Value = 90
            System.Threading.Thread.Sleep(1000)
            ProgressBar1.Value = 100
            'MsgBox("Complete!")
            ProgressBar1.Visible = False
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.