我最近开始使用 delphi,现在我想从一个目录中获取所有 mp3 文件。我想要类似 php 函数 glob() 的东西。
问问题
1056 次
5 回答
12
The old way of doing it is approx:
var
status : dword;
sr : TSearchRec;
begin
status := FindFirst('*.mp3',faAnyFile,sr);
while status = 0 do
begin
// sr.Name is the filename; add it to a list
// or something. Note there is no path so you
// may need to add that back on somewhere
status := FindNext(sr);
end;
SysUtils.FindClose(sr);
// ...
end;
于 2010-11-21T15:59:53.560 回答
3
试试 IOUtils.TDirectory。
于 2010-11-21T15:22:30.040 回答
1
如果您可以使用其他库,请查看 Jedi Code Library。
在单元 common\JclFileUtils 中,有一个紧凑的辅助函数:
function BuildFileList(const Path: string;
const Attr: Integer; const List: TStrings;
IncludeDirectoryName: Boolean = False): Boolean;
JCL 维护良好,包括了不起的扩展和一些 IDE 改进。(非常易于使用)JCL 安装程序可在http://sourceforge.net/projects/jcl/获得
于 2010-11-21T16:18:55.767 回答
1
Delphi FileCtrl单元中古老的TFileListBox是一个很好的解决方案。
它从 Delphi 1 开始就存在,关于 Delphi有一个很好的例子来说明如何使用它。
您可以将其放在表单上,设置Visible = False
,而不必担心。
它支持过滤(例如在扩展上),因此它可以很好地与您的 *.mp3 标准配合使用。
——杰伦
于 2010-11-21T23:21:35.000 回答
0
Delphi Area 的 TFindFile 是一个非常不错的免费组件:http: //www.delphiarea.com/products/delphi-components/findfile/
它将使您完全控制搜索文件/文件夹,线程或非
于 2010-11-21T18:26:00.450 回答