需要递归。给你一段程序
procedure Tform1.FileSearch(PathName:string);
var
F : TSearchRec;
Found : Boolean;
begin
ChDir(PathName);
Found := (FindFirst('*.*', faDirectory, F) = 0);
while Founddo
begin
if (F.Name = '.') or (F.Name = '..') then
begin
Found := (FindNext(F) = 0);
Continue;
end;
if (F.Attr and faDirectory)>0 then
begin
Application.ProcessMessages;
FileSearch(F.Name);
end;
if F.name = 'user.mdb' then
ListBox1.items.Add(GetCurrentDir);
Found := (FindNext(F) = 0);
end;
FindClose(F);
ChDir('../');
end;