delphi - Delphi中如何通过所有子目录搜索文件

标签 delphi

我已经在 Delphi 中实现了这段代码,它将搜索文件或给定的名称,但省略搜索所有子目录。如何做到这一点?

代码:

 if FindFirst(filePath,faAnyFile,searchResult)=0 then
  try
    repeat
    lbSearchResult.Items.Append(searchResult.Name);

    until FindNext(searchResult)<>0
  except
  on e:Exception do
  ShowMessage(e.Message);
  end; //try ends
  FindClose(searchResult); 

最佳答案

使用 Delphi XE 及更高版本,您可以查看 IOUtils.pas:

TDirectory.GetFiles('C:\', '*.dll', TSearchOption.soAllDirectories);

关于delphi - Delphi中如何通过所有子目录搜索文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6536525/

相关文章:

delphi - 如何仅设置 1 个特定大小的边框边缘?

Delphi泛型: How to spec "class that references its own type"

delphi - 如何处理很长的文件名(使用 TPath)?

json - 德尔福XE8 : Memory Leak with method datasnap server

delphi - 如何测试形状和面板是否在同一位置

delphi - 显示提示

Delphi - 无法让 HMAC-SHA256 通过 RFC 4231 测试向量

Delphi找不到System.dcu;默认路径设置应该是什么?

delphi - TDrawGrid OnSetEditText 触发两次 + 就地编辑器 + TCustomGrid

delphi - 在 Delphi 中,有一种使用 FireDAC 备份和恢复数据库的方法