Зачем куда-то что-то заносить, если задача стит только в посчитать?
Код:
function GetFileCount(APath : String) : Integer;
var
F : TSearchRec;
iFound : Integer;
begin
Result := 0;
APath := IncludeTrailingPathDelimeter(APath);
iFound := FindFirst(APath + '*.*',faAnyFile,F);
While iFound = 0 Do
Begin
If (F.Attr And faDirectory) = 0
Then Inc(Result)
Else
If (F.Name <> '.') And (F.Name <> '..')
Then Result := Result + GetFileCount(APath + F.Name);
ifound := FindNext(F);
End;
FindClose(F);
end;