主题:請問尋找整個C槽底下的檔案該如何寫?
tacomi
[专家分:0] 发布于 2006-07-26 11:58:00
小弟尋找檔案用
filesearch(aaa.exe,'c:\');
則可尋找出僅在c:\底下的檔案
若要尋找整個c:\底下所有的檔案該如何尋找
以上煩請知道的人爲小弟解答一下
謝謝!!
[樓 主] From:江蘇省電信 |
回复列表 (共4个回复)
沙发
wealthy [专家分:1840] 发布于 2006-07-26 12:08:00
这要用到文件管理和进程技术,我要下班了,下午再回答你
板凳
tacomi [专家分:0] 发布于 2006-07-26 12:15:00
這是在Delphi裡編寫的喔
期待你下午的回答~~
嘿嘿嘿
3 楼
wealthy [专家分:1840] 发布于 2006-07-26 14:08:00
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Memo1: TMemo;
procedure Maketree;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Maketree; //利用递归查找所有目录
var
sr:TsearchRec;
err:integer;
filePath:string;
begin
err:=findfirst('*.*',$37,sr);
while(err=0) do
begin
if sr.Name[1]<>'.' then
begin
if (sr.Attr and fadirectory)=0 then
begin
end;
if (sr.Attr and fadirectory)=16 then
begin
filepath:=expandfilename(sr.Name);
Memo1.lines.add(filepath); //显示找到的文件
chdir(sr.Name);
maketree;
chdir('..');
end;
end;
err:=findnext(sr);
end;
end;
procedure TForm1.Button1Click(Sender: TObject); //开始查找
begin
Memo1.lines.Clear;
chdir(edit1.text); //edit1.text里填要查找的文件(如c:\*.exe)
maketree;
end;
end.
4 楼
tacomi [专家分:0] 发布于 2006-07-26 15:58:00
真是太感謝你了
我可以跟你要MSN嗎
這樣以後有問題要問的話可以快的些
謝謝 ^_^
我来回复