PowerTCP FTP for .NET
ListDirectoryTree Method
Example 



Path to the remote directory. Null or empty string indicates the current working directory.
Search pattern. Null or empty string indicates all files.
Indicates whether empty directories should be excluded.
Get a recursive directory listing of remote files and directories within a directory tree.
Syntax
Public Function ListDirectoryTree( _
   ByVal remoteRoot As String, _
   ByVal pattern As String, _
   ByVal excludeEmptyDirs As Boolean _
) As List(Of ListEntry)
Dim instance As Ftp
Dim remoteRoot As String
Dim pattern As String
Dim excludeEmptyDirs As Boolean
Dim value As List(Of ListEntry)
 
value = instance.ListDirectoryTree(remoteRoot, pattern, excludeEmptyDirs)
public List<ListEntry> ListDirectoryTree( 
   string remoteRoot,
   string pattern,
   bool excludeEmptyDirs
)
public:
List<ListEntry^>^ ListDirectoryTree( 
   String^ remoteRoot,
   String^ pattern,
   bool excludeEmptyDirs
) 

Parameters

remoteRoot
Path to the remote directory. Null or empty string indicates the current working directory.
pattern
Search pattern. Null or empty string indicates all files.
excludeEmptyDirs
Indicates whether empty directories should be excluded.

Return Value

List of remote files.
Exceptions
ExceptionDescription
System.ArgumentExceptionpattern is an absolute path (starts with "/").
Remarks

Creates a List of remote files that can be used as a parameter for the Get method.

Empty directories are directories containing no files anywhere within their tree. An empty directory containing an empty directory is considered empty.

If your server returns the timestamp in a non-standard format, or uses non-english month abbreviations, set System.Globalization.DateTimeFormatInfo to the CultureInfo.DateTimeFormat of the appropriate CultureInfo.

DataIsBusy returns true while this method executes.

Example
This example demonstrates using the FTP control to retrieve multiple files using the FTP GET Command.
public void getMultipleFiles()
{
    //Retrieve a list of txt files to transfer.
    List<ListEntry> filesToGet = ftp1.ListDirectoryTree("MyTextFiles", "*.txt", true);

    //Tailor the list to not include a specific file.
    foreach (ListEntry entry in filesToGet)
    {
        if (entry.Name == "not_me.txt")
        {
            filesToGet.Remove(entry);
            break;
        }
    }

    //Retrieve the files.
    string workingDirectory = ftp1.GetDirectory();
    ftp1.Get(filesToGet, workingDirectory + "/MyTextFiles", myLocalDirectory, Synchronize.Off);
}
Public Sub getMultipleFiles()
    'Retrieve a list of txt files to transfer.
    Dim filesToGet As List(Of ListEntry) = ftp1.ListDirectoryTree("MyTextFiles", "*.txt", True)

    'Tailor the list to not include a specific file.
    For Each entry As ListEntry In filesToGet
        If entry.Name = "not_me.txt" Then
            filesToGet.Remove(entry)
            Exit For
        End If
    Next entry

    'Retrieve the files.
    Dim workingDirectory As String = ftp1.GetDirectory()
    ftp1.Get(filesToGet, workingDirectory & "/MyTextFiles", myLocalDirectory, Synchronize.Off)
End Sub
See Also

Reference

Ftp Class
Ftp Members


PowerTCP FTP for .NET Documentation Version 6.1
© 2023 Dart Communications. All Rights Reserved.
Send comments on this topic