delphi中如何实现模糊查找文件


本文整理自网络,侵删。

 
procedure   GetFilenames(sPath,   sFilename:   String;     AList:   TStrings);
//功能描述:   列出sPath目录中(不含子目录)所有文件名符合sFilename规则的文件名
//入口参数:
//     sPath           -   目录路径
//     sFilename   -   文件名
//出口参数:
//     AList           -   sPath目录中所有符合的文件名被添加到了这一列表中
var
   SR   :   TSearchRec;
begin
   if   FindFirst(sPath   +   sFilename,   faReadOnly   +   faHidden   +   faSysFile   +  faArchive   +   faAnyFile,   SR)   =   0   then
   begin
       repeat
           AList.Add(sPath   +   SR.Name);
       until   FindNext(SR)   <>   0;
       FindClose(SR);
   end;
end;

调用举例:   在ListBox1中列出   d:\aaa*.*
GetFilenames   ( 'd:\ ',   'aaa*.* ',   ListBox1.Items);

相关阅读 >>

Delphi写的一个屏幕截取函数

Delphi 英文单词第一个字母大写

Delphi 移动端使用 sqlite数据库查询

Delphi 控制台应用程序 hello world

tstringlist 常用操作

Delphi 通过控件句柄获取控件实例

Delphi string转为olevariant

Delphi extractclassname 字符串处理函数

Delphi idhttp中get与post的区别

Delphi 在线程中运行窗体

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



打赏

取消

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

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

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

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

评论

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