Download files from folders?

Sep 9, 2015 at 1:16 PM
Hey

I have found this ftpclient and it works great - for uploading specific files.

However I cant figure out how to loop trough all the folders in the ftp server, and listing the files names in each folder.

Can anybody help?

Much appriciated. Thanks:)
Jan 9, 2016 at 2:51 PM
this class should do it:

Imports System.IO
Imports System.Net.FtpClient
Imports System.Net
Public Class driveSync
Friend WithEvents ftp As FtpClient
Friend local As String = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)
Private queue As List(Of Object)

Public Sub New(ByVal drive As String, ByVal ftpP As String)
    Me.ftp = New FtpClient
    Me.queue = New List(Of Object)
    ftp.Host = "host"
    ftp.Credentials = New NetworkCredential(drive, ftpP)
    Me.SyncFolders(ftp.GetListing(ftp.GetWorkingDirectory))
End Sub

Private Sub SyncFolders(ByVal item)
    For Each explore As FtpListItem In item
        If explore.Type = FtpFileSystemObjectType.Directory Then
            SyncFolders(ftp.GetListing("/" & explore.FullName))
        Else
            If File.Exists(local & explore.FullName) Then

            Else

            End If
        End If

    Next



End Sub


Public Sub dispose()
    Me.ftp.Disconnect()
    Me.ftp.Dispose()
End Sub
End Class