下面这段代码来源于一本DELPHI学习的书上,运行测试通过,但发现一个重要问题,为什么当我查找'*12*'这样的通配符时(当然也可以不是12,只是举例),出现找到的文件有一些并非包括'12',当然12的也全出来,比如查到的文件有MMSBar_MobileQQ.ico这样一些,后来我把这些文件移到另一个文件内,就查不出来了,难道这些跟路径有关吗,MMSBar_MobileQQ.ico文件在QQ安装目录中的一个子目录中,一点问题也没有啊,哪位高人帮我看看,我急切想知道答案,谢谢,分多多给
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, FileCtrl;type
TForm1 = class(TForm)
DirectoryListBox1: TDirectoryListBox;
LabeledEdit1: TLabeledEdit;
Button1: TButton;
ListBox1: TListBox;
DriveComboBox1: TDriveComboBox;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
procedure findfiles(apath:string;afile:string);
{ Public declarations }
end;var
Form1: TForm1;
Targetfiles:string;
implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
screen.Cursor:=crHourGlass;
try
listbox1.Clear;
TargetFiles:=LabeledEdit1.text;
findfiles(Directorylistbox1.Directory,Targetfiles);
finally
screen.Cursor:=crdefault;
end;
end;
procedure tform1.findfiles(apath,afile:string);
var
findresult:integer;
fsearchrec,dsearchrec:Tsearchrec;
function isDirnotation(adirname:string):boolean;
begin
result:=((adirname='.') or (adirname='..'));
end;
begin
if apath[Length(apath)]<>'\' then
apath:=apath+'\';
findresult:=findfirst(apath+afile,faAnyFile+faHidden+faSysFile+faReadOnly,fsearchrec);
try
while findresult=0 do begin
listbox1.items.Add(fsearchrec.name);
findresult:=findnext(fsearchrec);
end;
findresult:=findfirst(apath+'*.*',fadirectory,dsearchrec);
while findresult=0 do begin
if((DSearchrec.Attr and fadirectory)= fadirectory) and
not isdirnotation(dsearchrec.name) then
findfiles(apath+dsearchrec.Name,targetfiles);
findresult:=findnext(dsearchrec);
end;
finally
findclose(fsearchrec);
end;end;procedure TForm1.Button2Click(Sender: TObject);
begin
listbox1.Items.add('aa');
end;
end.
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, FileCtrl;type
TForm1 = class(TForm)
DirectoryListBox1: TDirectoryListBox;
LabeledEdit1: TLabeledEdit;
Button1: TButton;
ListBox1: TListBox;
DriveComboBox1: TDriveComboBox;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
procedure findfiles(apath:string;afile:string);
{ Public declarations }
end;var
Form1: TForm1;
Targetfiles:string;
implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
screen.Cursor:=crHourGlass;
try
listbox1.Clear;
TargetFiles:=LabeledEdit1.text;
findfiles(Directorylistbox1.Directory,Targetfiles);
finally
screen.Cursor:=crdefault;
end;
end;
procedure tform1.findfiles(apath,afile:string);
var
findresult:integer;
fsearchrec,dsearchrec:Tsearchrec;
function isDirnotation(adirname:string):boolean;
begin
result:=((adirname='.') or (adirname='..'));
end;
begin
if apath[Length(apath)]<>'\' then
apath:=apath+'\';
findresult:=findfirst(apath+afile,faAnyFile+faHidden+faSysFile+faReadOnly,fsearchrec);
try
while findresult=0 do begin
listbox1.items.Add(fsearchrec.name);
findresult:=findnext(fsearchrec);
end;
findresult:=findfirst(apath+'*.*',fadirectory,dsearchrec);
while findresult=0 do begin
if((DSearchrec.Attr and fadirectory)= fadirectory) and
not isdirnotation(dsearchrec.name) then
findfiles(apath+dsearchrec.Name,targetfiles);
findresult:=findnext(dsearchrec);
end;
finally
findclose(fsearchrec);
end;end;procedure TForm1.Button2Click(Sender: TObject);
begin
listbox1.Items.add('aa');
end;
end.
解决方案 »
- 请问这段程序怎么实现关闭form1,打开form2的?
- ClientSocket.Socket.SendStream问题,
- 性欲被扣,郁闷散分
- 有一个简单的问题请教 关于select sum() from table where field=:fieldvalues
- 哪位大师能给我一个用delphi或c语言实现的生产者-消费者问题的源程序?
- 请问谁能提供一份 <<Delphi 5开发人员指南>>的配书源码 的下载地址?3Q~~
- delphi 中如何调用 CHM格式的帮助文件
- QuickRep问题?
- 一个关于colordialog的问题
- 寻找azpr的注册码,100分,先谢谢了
- adoquery分批读取数据
- 关于调用VC动态库
改成
listbox1.items.Add(fsearchrec.FindData.cAlternateFileName);你就明白了,