Registriert seit: 6. Apr 2005
10.109 Beiträge
|
Re: Unterordner eines Ordners suchen
27. Okt 2005, 13:16
Hier das ganze in Grün - aber mit TreeView zur Visualisierung:
Delphi-Quellcode:
procedure AllFolders(root: string; nodes: TTreeNodes; tnParent: TTreeNode);
var
sr: TSearchRec;
tn: TTreeNode;
begin
root := IncludeTrailingPathDelimiter(root);
if FindFirst(root + '*.*', faAnyFile, sr) = 0 then
try
repeat
Application.ProcessMessages;
if (sr.Name <> '.')
and (sr.Name <> '..')
and ((sr.Attr and faDirectory) = faDirectory) then
begin
tn := nodes.AddChild(tnParent, sr.Name);
AllFolders(root + sr.Name, nodes, tn);
end else
Continue;
until FindNext(sr) <> 0;
finally
FindClose(sr);
end;
end;
procedure TDemoForm.ListButtonClick(Sender: TObject);
begin
with TreeView do
begin
Items.Clear;
Items.BeginUpdate;
AllFolders('C:\DATEN', Items, nil);
Items.EndUpdate;
end;
end;
marabu
|
|
Zitat
|