Question

I am trying to make a utility to scan our FTP site for old files.

I have come across Indy FTP as part of RAD Studio today and like how it works, but how do I do the following?

  1. Get a list of files/directories that I can see (go from TIdFTP.List() to listbox).
  2. Narrow those results by a date (showing filename/path)
Was it helpful?

Solution

TIdFTP has a DirectoryListing collection that you can loop through after calling TIdFTP.List(). Each item in the collection has FileName, ItemType, and ModifiedDate properties, amongst many others.

There are many FTP listing formats used online, and Indy implements many parsers for them, however most of the parsers are not enabled by default. If the FTP server(s) you are connecting to do not support the MLSD command (that parser is always enabled), and/or you are setting the TIdFTP.UseMLIS property to false, then you will need to either:

  1. add individual IdFTPListParse... units to your uses clause to enable just the parsers for the particular formats that you want to support.

  2. add the IdAllFTPListParsers unit to your uses clause to enable all of the parsers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top