利用递归技术就可以.
这是我程序中的一个片断------
function tform1.FindFiles(Path: TFileName; node: ttreenode): TLIST;
var
TS: TSearchRec;
NextPath: TFileName;
rslt: integer;
dirnode: ttreenode;
begin
Rslt := FindFirst(Path + '*.*', faAnyFile, TS);
while Rslt = 0 do
begin
if (TS.Name <> '.') and (TS.Name <> '..') then
if (ts.Attr and faDirectory <> faDirectory) then
treeview1.items.addchild(node, ts.name)
else
begin
NextPath := Path + ts.Name + '/';
dirnode := treeview1.items.addchild(node, ts.name);
Findfiles(NextPath, dirNODE);
end;
Rslt := FindNext(TS);
end;
FindClose(TS);
end;
调用:
findfiles('c:/',nil);