可是如下代码要加入盘符才行
如何不用输入盘符能输入文件名,就能实现搜索功能
多谢了
我的代码如下:procedure search(dir:string);
var targetpath:string;
sr:tsearchrec;
begin
targetpath:=extractfilepath(dir);
if findfirst(dir,faanyfile,sr)=0 then
repeat
if((sr.Name '.')and(sr.Name '..'))
and((filegetattr(targetpath+sr.Name)and fadirectory) fadirectory) then
form1.Memo1.Lines.Add(targetpath+sr.Name);
until findnext(sr) 0;
if findfirst(dir,faanyfile,sr)=0 then
repeat
if ((sr.Name '.')and(sr.Name '..'))
and((filegetattr(targetpath+sr.Name)and fadirectory)=fadirectory) then
search(targetpath+sr.Name+ '*.* ');
until findnext(sr) 0;
end;
procedure TForm1.Button1Click(Sender:TObject);
begin
memo1.Clear;
search(edit1.Text);
messagedlg( '文件搜索完毕 ',mtinformation,[mbok],0);
end;
procedure TForm1.FormCreate(Sender:TObject);
begin
edit1.Text:= 'c: ';
end;