Ver Mensaje Individual
  #1  
Antiguo 13-04-2007
mierda mierda is offline
Miembro
 
Registrado: may 2006
Posts: 129
Reputación: 19
mierda Va por buen camino
Rellenar treeview con un directorio recursivamente

Hola tios, estoy intentando rellenar un treeview recursivamente con las carpetas y ficheros de texto de un directorio, y si solo hay una subcarpeta me funciona perfectamente, pero cuando paso de ahi se me va de bola ... a ver si me arrojais un poco de luz

Gracias

Código Delphi [-]
 
procedure TForm1.RastreaDir( Dir: string );
var
   FileSearch:  TSearchRec;
   nodo1,nodo2,nodo3,nodo4,nodo5,nodo6, nodo7, nodo8, nodo9,nodo10: TTreeNode;
begin
   num  := num +1;
   ChDir ( Dir );
   if FindFirst ( '*.*', faDirectory, FileSearch )=0 then
   repeat
     if ( (FileSearch.Attr and fadirectory) = fadirectory) then
       begin
         if  (FileSearch.Name <> '.')and (FileSearch.Name <> '..') then
           begin
             if num = 1 then
               begin
                 nodo1 := arbol.Items.Add(nil,filesearch.name);
                 nodo1.selectedindex := num;
               end
             else
               begin
                nodo1 := arbol.Items.Addchild(nodo1,filesearch.name);
                nodo1.selectedindex := num;
               end;
             RastreaDir( Dir + '\' + FileSearch.Name );
           end;
       end
     else
       begin
         Memo1.Lines.Add( Dir +'\'+FileSearch.Name );
         arbol.Items.AddChild(nodo1,inttostr(num) + ' ' + filesearch.name);
       end;
   until FindNext( FileSearch ) <> 0;
   num := num -1;
   FindClose( FileSearch );
end;
Responder Con Cita