FTP File List

FTP File List

Demonstrates the power of GetList method and FtpList class.

A utility that connects to a given FTP server and displays file list for a given directory (both VB.NET and C#).

The format of the file list (FTP LIST command) differs from server to server. But with Rebex FTP for .NET, retrieving and using list of files in directory is extremely easy - GetList method does all the hard work and parses all common list formats automatically! Following code snippet displays the list of files in the remote directory:


// select the desired directory

// retrieve and display the list of files and directories
FtpList list = ftp.GetList();
foreach (FtpItem item in list)
    Console.Write(item.Length.ToString().PadLeft(10, ' '));
    Console.Write(" {0}", item.Name);


' select the desired directory

' retrieve and display the list of files and directories
Dim list As FtpList = ftp.GetList()
Dim item As FtpItem
For Each item In list
    Console.Write(item.Length.ToString().PadLeft(10, " "c))
    Console.Write(" {0}", item.Name)
Next item

It is that simple!

Included in

See also: