The OpenDirectory method opens the specified directory on
the server using the LIST command. The contents of the directory can
be read using the GetFirstFile and GetNextFile
methods. The directory listing is returned on the data channel in one
of several different formats. The library can recognize listing
formats generated by UNIX, VMS and Windows servers, as well as those
of other servers which emulate one of those common formats. Once the
complete directory listing has been read, the directory must be
closed by calling the CloseDirectory method.
Because the directory listing is returned on the data channel, a
file transfer cannot be performed while the directory is in the
process of being read by the client. Applications which need to
collect a list of files to download should first open the directory,
read the contents and store the file names in an array. After the
directory has been closed, the application can then start
transferring the files to the local system.
Some servers may not support file listings for any directory other
than the current working directory. If an error is returned when
specifying a directory name, try changing the current working directory
using the ChangeDirectory method and then call this method again,
passing NULL or an empty string as the lpszDirectory parameter.
To obtain a list of all files in a directory using a single
function call, use the EnumFiles method. If the server lists
files in a format that is not recognized by the library, the
GetFileList method can be used to obtain an unparsed file
listing from the server.