Mega Code Archive

 
Categories / Delphi / Files
 

Get all files from a directory

Title: Get all files from a directory procedure ListFileDir(Path: string; FileList: TStrings); var SR: TSearchRec; begin if FindFirst(Path + '*.*', faAnyFile, SR) = 0 then begin repeat if (SR.Attr faDirectory) then begin FileList.Add(SR.Name); end; until FindNext(SR) 0; FindClose(SR); end; end; Example usage: ListFileDir('C:\WINDOWS\', ListBox1.Items);