简体   繁体   English

如何获取和过滤TIdFTP的文件列表?

[英]How do I get and filter a list of files from TIdFTP?

I am trying to make a utility to scan our FTP site for old files. 我正在尝试制作一个实用程序来扫描我们的FTP站点中的旧文件。

I have come across Indy FTP as part of RAD Studio today and like how it works, but how do I do the following? 今天,作为RAD Studio的一部分,我遇到了Indy FTP,并且喜欢它的工作原理,但是我该怎么做?

  1. Get a list of files/directories that I can see (go from TIdFTP.List() to listbox). 获取我可以看到的文件/目录列表(从TIdFTP.List()到列表框)。
  2. Narrow those results by a date (showing filename/path) 按日期缩小结果范围(显示文件名/路径)

TIdFTP has a DirectoryListing collection that you can loop through after calling TIdFTP.List() . TIdFTP有一个DirectoryListing集合,您可以在调用TIdFTP.List()之后循环遍历。 Each item in the collection has FileName , ItemType , and ModifiedDate properties, amongst many others. 集合中的每个项目都具有FileNameItemTypeModifiedDate属性,以及许多其他属性。

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. 在线使用了许多FTP列表格式,并且Indy为此实现了许多解析器,但是默认情况下,大多数解析器均未启用。 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: 如果您要连接的FTP服务器不支持MLSD命令(始终启用该解析器),并且/或者将TIdFTP.UseMLIS属性设置为false,那么您将需要:

  1. add individual IdFTPListParse... units to your uses clause to enable just the parsers for the particular formats that you want to support. 将单独的IdFTPListParse...单元添加到您的uses子句中,以仅启用要支持的特定格式的解析器。

  2. add the IdAllFTPListParsers unit to your uses clause to enable all of the parsers. 在添加IdAllFTPListParsers单元您uses条款,以使所有的解析器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM