Back to product page

ListDir method

Lists contents of a directory on the server.




  • Basic
The ListDir(object,RemotePath) syntax has these parts:
objectAn expression evaluating to an object of type wodFtpDLX.
RemotePathOptional. A Variant value. Full path to a directory on the server.


ListDir method will send request to the server to retrieve FULL listing of a directory, given by RemotePath argument. Once server sends data, ListItems event will be fired containing all the file listed by the server - each one in separate line, split by CRLF sequence. If server supports MLSD/MLST extensions, this command will send MLSD. If those extensions are not supported, LIST command is sent (in FTP protocol).

Once completed, Done event will be fired. If no error occurs, ErrorCode argument in Done event will be set to 0 (zero). If error occurred, ErrorCode will hold number for the error, and ErrorText will contain description for the error. You can use DirItems property to access parsed collection of items from listed directory.

To get only filenames (and directory names) for specific path, you can use ListNames method.

No wildcards can be used for RemotePath argument. RFC protocol specifications for FTP and SFTP do not allow them.

Do not forget that RemotePath should always specify full absolute path (i.e. /home/joe/something) instead of relative path (i.e. joe/something).