I want List all files in a FTP server for Indexing(Main Dir and Sub Directories).
How can I get a full list of the files accessible in the server?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Indy has a
TIdFTPcomponent, which has aList()method and aDirectoryListingproperty. CallList()and then loop through the resultingDirectoryListingas needed. Each item in theDirectoryListingwill tell you whether it is a file or a subfolder. If you need to index an entire system, you will have to callList()in a recursive loop for each subfolder.Something to keep in mind – there are literally hundreds of platform-specific directory listing formats still being used by FTP servers on the Internet today. The
LISTcommand outlined in the original FTP specification, RFC 959, did not define any kind of formatting to be used for listings, so systems were free to use whatever they wanted to use, and they did do exactly that over the years. Windows and Unix formats are common, but they are not required. A formal listing format was not defined until RFC 3659 in theMLSDextension to FTP, which replaces the oldLISTcommand (TIdFTP.List()does useMLSDif the server supports it).I mention this because
TIdFTPin Indy 10 uses a plugin system to support many of these different listing formats. Each format is implemented in a separateIdFTPListParse...unit in Indy. By default, only theNLSTandMLSDformats are always enabled. For any other listing format you want to support, you need to include the appropriateIdFTPListParse...unit into yourusesclause in order forTIdFTPto recognize it. For example,IdFTPListParseUnixandIdFTPListParseWindows. Alternatively, there is aIdAllFTPListParsersunit that enables all of the available parsers. When you callTIdFTP.List(), theTIdFTP.DirFormatproperty will be set to the name of the parser that was used to parse the raw listing data.