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 firedac压缩和修复ms access数据库

Delphi 2009 泛型容器单元(generics.collections)[2]: tqueue<t>

Delphi 对txt文件的操作

Delphi 读取图像文件base64编码加载到image组件显示图片

Delphi 获取listbox1多选的值

Delphi中httpencode使用注意事项

Delphi xe10 获取屏幕截图

Delphi下对dbf文件进行物理删除

Delphi调用http接口上传文件

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



打赏

取消

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

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

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

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

评论

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