Ver Mensaje Individual
  #2  
Antiguo 22-04-2005
Avatar de roman
roman roman is offline
Moderador
 
Registrado: may 2003
Ubicación: Ciudad de México
Posts: 20.269
Reputación: 10
roman Es un diamante en brutoroman Es un diamante en brutoroman Es un diamante en bruto
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 [-]
// Uso
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
Responder Con Cita