vl. Hilft dir ja das hier:
Das teil durchsucht einen Ordner -Unterordner und legt dementsprechend Nodes an...
EDIT: Das war das falsche...
Hier also das richtige...
Delphi-Quellcode:
procedure TDirectorySearch.scan(path: string; tiefe:integer);
var SR:TSearchRec;
tmparray:array of string;
i:integer;
tn:TTreeNode;
begin
SetLength(tmparray,0);
if FindFirst(path+'*', faAnyFile, SR) = 0 then
begin
repeat
if (SR.Attr and faDirectory = faDirectory) and
not ((SR.Name=',') or (SR.Name='.') or (SR.Name='..')) then
begin
with fTreeView.Items.AddChild(fTreeView.Selected,sr.Name+'/') do
begin
tn:=fTreeView.Selected;
Selected:=true;
scan(path+sr.Name+'/',tiefe+1);
fTreeView.Selected:=tn;
end;
end else
if not ((SR.Name=',') or (SR.Name='.') or (SR.Name='..') or (SR.Name='.directory')) and
((AnsiLowerCase(extractfileext(sr.Name))='.mp3') or
(AnsiLowerCase(extractfileext(sr.Name))='.ogg') or
(AnsiLowerCase(extractfileext(sr.Name))='.aac') or
(AnsiLowerCase(extractfileext(sr.Name))='.wav')) then
begin
SetLength(tmparray,Length(tmparray)+1);
tmparray[High(tmparray)]:=sr.Name;
end;
until FindNext(SR) <> 0;
end;
if High(tmparray)>=0 then
for i:=0 to High(tmparray) do
begin
fTreeView.Items.AddChild(fTreeView.Selected,tmparray[i]).MakeVisible;
end;
end;