Private m_ftp As FTP Private _LocalSubDirectory As String = "" Private _RemoteDirectories As New ArrayList Private Sub ftpDownload(ByVal ftpDirectory As String) m_ftp.RemoteDirectory = ftpDirectory Dim ftpDirectoryName As String = "" Dim ftpFiles As FTPFiles = m_ftp.EnumFiles For Each file As FTPFile In ftpFiles If file.Type = FTPFileType.Directory Then ftpDirectoryName = file.Name If Not (ftpDirectoryName.EndsWith(" .") Or ftpDirectoryName.EndsWith(" ..")) Then Dim posL As Integer = ftpDirectoryName.IndexOf(" ") ftpDirectoryName = ftpDirectoryName.Substring(posL + 1, ftpDirectoryName.Length - posL - 1) _RemoteDirectories.Add(ftpDirectoryName) If ftpDirectoryHasFolders(ftpDirectoryName) Then _LocalSubDirectory += ftpDirectoryName + "\" ftpDownload(ftpDirectoryName) End If End If End If Next m_ftp.ChangeDirectory("..") End Sub Private Function ftpDirectoryHasFolders(ByVal ftpDirectory As String) As Boolean Dim result As Boolean = False m_ftp.RemoteDirectory = ftpDirectory Dim ftpFiles As FTPFiles = m_ftp.EnumFiles For Each file As FTPFile In ftpFiles If file.Type = FTPFileType.Directory Then Dim ftpDirectoryName As String = file.Name If Not (ftpDirectoryName.EndsWith(" .") Or ftpDirectoryName.EndsWith(" ..")) Then result = True End If End If Next m_ftp.ChangeDirectory("..") Return result End Function
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)