ListDirectory or GetFileList methods return 0 elements, though file download works. What's wrong?

FTP protocol (RFC 959) doesn't have a uniform way to get the listing of the directory.

LIST command offered by the FTP protocol returns some text strings that describe directory contents. The format of those strings is completely undefined. There exist over 400 (or maybe even more) formats used by different servers. Most common formats are Unix format and DOS/Windows formats, but even then you can see differences and sometimes impossibility to parse the result.

GetFileList method uses LIST command, results of which are reported via OnTextDataLine event. You can then use ParseFileListEntry method (it supports DOS/Windows and Unix formats) to parse the output. If ParseFileListEntry fails, you still can write your own parser or plug the external library for parsing the listing.

Extensions to FTP standard introduced MLST/MLSD commands (MLST returns information about one file via command channel and MLSD returns directory listing via data channel) which returns result in predefined machine-parseable format. TElSimpleFTPSClient has MLSD and ParseMLSDEntry methods to work with this extension command. Note, that not all servers support MLSD. If the extension command is supported, this support is reported via response to FEAT command. FEAT command is handled by TElSimpleFTPSClient internally and ExtMLSTSupported property is set to true if the server reports support.

ListDirectory is a high-level method that attempts to use MLSD command when available, otherwise it uses LIST command.

In your particular case the server neither supports MLSD command nor provides the listing in one of common/supported formats.

First thing to do in order to solve the problem is to take the sample in \Samples\\FTPSBlackbox\Client folder, connect to the server and try to list the directory. Then check the produced log to see what response to FEAT command is given by the server and in what format the listing is produced. Then you can decide what to do next.

Ready to get started?

Learn more about SecureBlackbox or download a free trial.

Download Now