Displaying a Directory
Use FirstFirst(), FindNext(), FindClose to display a directory.
procedure TForm1.Button1Click(Sender: TObject);
var
  Found: Integer;
  SearchRec: TSearchRec;
  Path: String;
begin
  Path := 'C:\*.*';
  Found := FindFirst(Path, faAnyFile, SearchRec);
  while Found = 0 do
    begin
      if SearchRec.Attr and faDirectory = faDirectory then
        ListBox1.Items.Add('[' + SearchRec.Name + ']')
      else
        ListBox1.Items.Add(SearchRec.Name);
      Found := FindNext(SearchRec);
    end;
  FindClose(SearchRec);
end;
Notes:
The files are not sorted.
Home