Mega Code Archive

 
Categories / Delphi / Files
 

Detect all files in directory

Title: Detect all files in directory Use SearchFiles procedure. You should specify a directory, and after that, this function returns a list of files in this folder. Main moments are FindFirst and FindNext functions. procedure TForm1.SearchFiles(St: string); var MySearch: TSearchRec; FindResult: Integer; begin FindResult:=FindFirst(St+'\*.*', faAnyFile, MySearch); if (MySearch.Name&lt&gt'.')and(MySearch.Name&lt&gt'..') then Memo1.Lines.Add(MySearch.Name); while FindNext(MySearch)=0 do begin if (MySearch.Attr&lt&gtfaDirectory)and (MySearch.Name&lt&gt'.')and (MySearch.Name&lt&gt'..') then Memo1.Lines.Add(MySearch.Name); end; end;