如何查找文件?

nx_lsj123456 2013-01-27 03:25:14
如何利用DELPHI语言,查找一个特定的文件,获取文件存储路径?
...全文
185 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
hsfzxjy 2013-01-28
  • 打赏
  • 举报
回复
一路随云 2013-01-27
  • 打赏
  • 举报
回复
FindFirst FindNext FindEnd; 贴一个我自己写的函数;
procedure GetSubFiles(Path,Ext:string; var List:TStringList);
var
  n: Integer;
  F: TSearchRec;
begin
if Path[Length(Path)] <> '\' then Path:=path+'\';
n:=FindFirst(Path+'*.*',63,f);
while n=0 do
begin
Application.ProcessMessages;
 if ((f.Name)[1] <> '.') then
 begin
    if Copy(F.Name,Length(f.Name)-(length(ext)-1),Length(ext)) =ext then List.Add(Path+f.Name);
    if f.Attr=faDirectory then GetSubFiles(Path+f.Name,ext,List);
 end;
 n:=FindNext(f);
end;
end;
看这个 函数把递归把所有类型文件返回到一个列表内 你再遍历这个列表看看文件在不再就好了
haitao 2013-01-27
  • 打赏
  • 举报
回复
findfirst/findnext 多级子目录还要递归深入
hongss 2013-01-27
  • 打赏
  • 举报
回复
遍历?需求太模糊。。。

2,507

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧