edtFTPnet/Free - Open-source FTP component for .NET | Download
 How to get a directory listing

There are two basic ways to get a list of the files in a particular directory on an FTP server. The simpler way gets the names of the files using the GetFiles() method:

string[] files = ftpConnection.GetFiles();

This results in the files array containing the name of the files and directories in the current working directory on the server. 

Often more information that just the name of the file/directory is required. In such cases, the GetFileInfos() method should be used:

FTPFile[] fileDetails = ftpConnection.GetFileInfos();

This method returns an array of FTPFile objects containing information about the files in the directory - details such as the size of the file and whether or not it is a directory. 

If a listing of a directory other than the current working directory is required it is recommended that the remote working directory be changed to that directory, as described in How to change directories. The relative or absolute path may be passed to either method, but some FTP servers do not support this feature. In these cases changing directories should work.