Показать сообщение отдельно
  #5  
Старый 09.09.2006, 14:52
Аватар для Decoding
Decoding Decoding вне форума
Местный
 
Регистрация: 03.06.2006
Адрес: Почту найдете на моем сайте
Сообщения: 576
Версия Delphi: D10.2
Репутация: 214
По умолчанию

Знаешь что такое рекурсия?

Код:
procedure GetAllFiles( Path: string; Lb: TListBox );
var
  sRec: TSearchRec;
  isFound: boolean;
begin
   isFound := FindFirst( Path + '\*.*', faAnyFile, sRec ) = 0;
   while isFound do
   begin
      if ( sRec.Name <> '.' ) and ( sRec.Name <> '..' ) then
      begin
         if ( sRec.Attr and faDirectory ) = faDirectory then
            GetAllFiles( Path + '\' + sRec.Name, Lb );
         Lb.Items.Add( Path + '\' + sRec.Name );
      end;
      Application.ProcessMessages;
      isFound := FindNext( sRec ) = 0;
   end;
   FindClose( sRec );
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
   GetAllFiles( 'c:\windows', ListBox1 );
end;
Ответить с цитированием