Mega Code Archive

 
Categories / Delphi / Files
 

How to list files in a directory

//This code will list all the files in the windows directory and display it on a //memo field. procedure TForm1.Button1Click(Sender: TObject); var SR: TSearchRec; begin if FindFirst( 'c:\WinNT\*.*', faAnyFile, SR) = 0 then begin repeat if (SR.Attr <> faDirectory) then begin memo1.lines.Add(SR.Name); end; until FindNext(SR) <> 0; FindClose(SR); end; end;