还是用FindFirst、FindNext函数;
var
SearchRec: TSearchRec;
AllFileAndDir: TStringList;
procedure TForm1.FormCreate(Sender: TObject);
begin
AllFileAndDir := TStringList.Create;
end;
procedure TForm1.SearchClick(Sender: TObject);
begin
FindFirst(''c:/*.*', faAnyFile + faDirectory, SearchRec);
AllFileAndDir.Add(SearchRec.Name);
while (FindNext(SearchRec) = 0) do
AllFileAndDir.Add(SearchRec.Name);
FindClose(SearchRec);
end;
你可以参看FindFirst、FindNext、FindClose和TSearchRec在Delphi中的说明。