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 theGetFiles() 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:
This
method returns an array ofFTPFile 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.