如何利用DELPHI语言,查找一个特定的文件,获取文件存储路径?

解决方案 »

  1.   

    findfirst/findnext
    多级子目录还要递归深入
      

  2.   

    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;看这个  函数把递归把所有类型文件返回到一个列表内  你再遍历这个列表看看文件在不再就好了