Código Delphi
[-]
procedure DirList(Path: String; List: TStrings);
var
SearchRec: TSearchRec;
begin
Path := IncludeTrailingPathDelimiter(Path);
if FindFirst(Path + '*.*', faAnyFile, SearchRec) = 0 then
begin
List.BeginUpdate;
repeat
if (SearchRec.Name <> '.') and (SearchRec.Name <> '..') then
begin
if (SearchRec.Attr and faDirectory = faDirectory) then
begin
List.Add(Path + SearchRec.Name + '\');
DirList(Path + SearchRec.Name, List);
end
else
List.Add(Path + SearchRec.Name);
end;
until FindNext(SearchRec) <> 0;
List.EndUpdate;
end;
FindClose(SearchRec);
end;
Código Delphi
[-]
DirList('C:\Mis documentos', ListBox1.Items);
No es la forma óptima y si lo ejecutas contra 'C:\' prepárate a esperar un buen rato.
// Saludos