F
fossil
Unregistered / Unconfirmed
GUEST, unregistred user!
我得查找文件的程序。为什么最后查找文件的数量总返回0啊,明明有×。BMP文件
Function TForm1.GetFileNum(path:string) : integer; //在目录下查找文件;
var
rec:Tsearchrec;
begin
Result := 0;
Findfirst(path+'*.*',faAnyFile,rec);
while FindNext(rec) = 0 do
begin
if ((rec.Attr and faDirectory)=faDirectory) and (rec.name<>'.') and (rec.Name<>'..') then //判断有没有目录存在
GetFileNum(path+rec.name+'/');
if ((rec.Attr and faDirectory)<>faDirectory) and (UpperCase(ExtractFileExt(rec.name))='.BMP') then
begin
inc(Result) ;
end;
application.ProcessMessages;
end;
findclose(rec);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
a: Integer;
begin
a := GetFileNum('d:/' );
ShowMessage(IntToStr(a));
end;
Function TForm1.GetFileNum(path:string) : integer; //在目录下查找文件;
var
rec:Tsearchrec;
begin
Result := 0;
Findfirst(path+'*.*',faAnyFile,rec);
while FindNext(rec) = 0 do
begin
if ((rec.Attr and faDirectory)=faDirectory) and (rec.name<>'.') and (rec.Name<>'..') then //判断有没有目录存在
GetFileNum(path+rec.name+'/');
if ((rec.Attr and faDirectory)<>faDirectory) and (UpperCase(ExtractFileExt(rec.name))='.BMP') then
begin
inc(Result) ;
end;
application.ProcessMessages;
end;
findclose(rec);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
a: Integer;
begin
a := GetFileNum('d:/' );
ShowMessage(IntToStr(a));
end;