function GetFileCount(ThePath,Ext:string):integer;
var
num:integer;
sr:TSearchRec;
begin
num :=0;
if ThePath[length(ThePath)]<>'\' then
ThePath :=ThePath+'\';
if (FindFirst(ThePath+Ext,faAnyFile,sr)=0 then
begin
num :=num+1;
while (FindNext(sr)=0) do
num :=num+1;
end;
result :=num;
end;
end;