DELPHI 반복 파일 코드

1055 단어 귀속두루Delphi
procedure MakeFileList(Path,FileExt:string;var List:TStringList);
//Path          。           
//FileExt         '.exe' 
//List             
//2012-12-13     
var
sch:TSearchrec;
begin
if List=nil then List:=TStringlist.Create;
Path:=Trim(Path);
if Path[Length(Path)] <> '\' then Path := Path+ '\';

if not DirectoryExists(Path) then
begin
    List.Clear;
    exit;
end;
if FindFirst(Path + '*', faAnyfile, sch) = 0 then
begin
    repeat
       Application.ProcessMessages;
       if ((sch.Name = '.') or (sch.Name = '..')) then Continue; //                   

       if DirectoryExists(Path+sch.Name) then    //        ,             
       begin
         MakeFileList(Path+sch.Name,FileExt,List);
       end

       else

       begin
         if (UpperCase(extractfileext(Path+sch.Name)) = UpperCase(FileExt)) or (FileExt='.*') then
         List.Add(Path+sch.Name);
       end;
    until FindNext(sch) <> 0;
    SysUtils.FindClose(sch);
end;
end;

좋은 웹페이지 즐겨찾기