delphi 获取指定当前目录下指定文件扩展名所有文件


本文整理自网络,侵删。

 
procedure MakeFileList(const Path, FileExt: string; AFileList: TStrings);
var
  sch: TSearchRec;
  tmpPath: string;
begin
  if RightStr(Trim(Path), 1) <> '\' then
    tmpPath := Trim(Path) + '\'
  else
    tmpPath := Trim(Path);
  if not DirectoryExists(tmpPath) then
    Exit;
  if FindFirst(tmpPath + '*', faAnyFile, sch) = 0 then
  begin
    repeat
      if ((sch.Name = '.') or (sch.Name = '..')) then
        Continue;
      if (UpperCase(ExtractFileExt(tmpPath + sch.Name)) = UpperCase(FileExt)) or (FileExt = '.*') then
        AFileList.Add(tmpPath + sch.Name);
    until FindNext(sch) <> 0;
    System.SysUtils.FindClose(sch);
  end;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
MakeFileList('c:\','.exe',memo1.Lines);
end;

相关阅读 >>

Delphi 检查当前用户权限

Delphi如何判断一个combobox是否处于下拉状态

Delphi删除目录及子目录及所有目录下的文件

Delphi 取最前窗口标题(不重复)

Delphi获取当前计算机所有盘符

Delphi使用idhttp.get('') 造成假死(堵塞),请问线程idhttp怎么才能做到不出错?

Delphi实现票据精确打印

Delphi 执行cmd并取得返回值

Delphi 热键声明和使用

Delphi 验证guid的函数

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...