Mega Code Archive
Belirtilen klasör ve alt klasörlerde belirtilen maska göre dosya listesini bulma
Procedure FindFiles(const Path, Mask: string; IncludeSubDir: boolean; Out List:TStringList);
var
FindResult: integer;
SearchRec : TSearchRec;
begin
FindResult := FindFirst(Path + Mask, faAnyFile - faDirectory, SearchRec);
while FindResult = 0 do
begin
{ do whatever you'd like to do with the files found }
List.Add(Path + SearchRec.Name);
FindResult := FindNext(SearchRec);
end;
{ free memory }
FindClose(SearchRec);
if not IncludeSubDir then
Exit;
FindResult := FindFirst(Path + '*.*', faDirectory, SearchRec);
while FindResult = 0 do
begin
if (SearchRec.Name <> '.') and (SearchRec.Name <> '..') then
FindFiles (Path + SearchRec.Name + '\', Mask, TRUE,List);
FindResult := FindNext(SearchRec);
end;
{ free memory }
FindClose(SearchRec);
end;
//Kullanımı
Var
i:Integer;
liste:TStringList;
begin
liste:=TStringList.Create;
FindFiles(GetCurrentDir+'\','*.Dat',False,liste);
Memo1.Lines.Clear;
Memo1.Lines:=Liste;
liste.Free;
end;