PowerTCP FTP for .NET
List 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. Can include arguments.
The ListType listing technique to use.
Returns a flat listing of remote files and directories contained within a single directory.
Syntax
Public Function List( _
   ByVal remoteRoot As String, _
   ByVal pattern As String, _
   ByVal type As ListType _
) As Listing
Dim instance As Ftp
Dim remoteRoot As String
Dim pattern As String
Dim type As ListType
Dim value As Listing
 
value = instance.List(remoteRoot, pattern, type)
public Listing List( 
   string remoteRoot,
   string pattern,
   ListType type
)
public:
Listing^ List( 
   String^ remoteRoot,
   String^ pattern,
   ListType type
) 

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. Can include arguments.
type
The ListType listing technique to use.

Return Value

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

The pattern can include arguments, such as "-r" for recursive or "-a" to include hidden files. If remoteRoot is specified (not null or an empty string), and pattern is intended to only contain arguments, you must prepend a wildcard to pattern, e.g. "* -a".

If your server returns the timestamp in a non-standard format, or uses non-english month abbreviations, set Ftp.Session.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 obtain a directory listing from a remote server.
private void getListing()
{
    //Connect and log into the server, and get a listing
    ftp1.Connect(myServer);
    ftp1.Authenticate(myUsername, myPassword);
    Listing listing = ftp1.List("", "", ListType.Full);

    //Add all the list entries in the listing to a listbox
    foreach (ListEntry entry in listing)
        listBox1.Items.Add(entry.Text);

    //Logout of the server
    ftp1.Close();
}
Private Sub getListing()
    'Connect and log into the server, and get a listing
    ftp1.Connect(myServer)
    ftp1.Authenticate(myUsername, myPassword)
    Dim listing As Listing = ftp1.List("", "", ListType.Full)

    'Add all the list entries in the listing to a listbox
    For Each entry As ListEntry In listing
        listBox1.Items.Add(entry.Text)
    Next entry

    'Logout of the server
    ftp1.Close()
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