ADirectory 要找的目录
CurrentDir(默认=空调用就可以)
AllFileList (TStringList,查找到的文件列表)
procedure TNetFile.XCollectFiles(ADirectory, CurrentDir: String);
var
Path : String;
Ret : Integer;
DirFile : TSearchRec;
begin
Path := ADirectory+'/*.*';
Ret := FindFirst(Path,faAnyFile,DirFile);
If Ret <> NO_ERROR then Exit;
Try
while Ret = NO_ERROR do
begin
if (DirFile.Name ='.') Or (DirFile.Name = '..') then
begin
Ret := FindNext(DirFile);
Continue;
end;
If (DirFile.Attr and (faDirectory or faVolumeID)) = 0 Then //是文件
AllFileList.Add(CurrentDir+'/'+DirFile.Name) //是目录
else
XCollectFiles(ADirectory+'/'+DirFile.name,CurrentDir+'/'+DirFile.Name);
Ret := FindNext(DirFile);
end;//while do
Finally
FindClose(DirFile);
end;
end;