3
3DDELPHI
Unregistered / Unconfirmed
GUEST, unregistred user!
各位大师:
我编写了一个查询文件的小程序,但不管文件是否存在执行的结果都是文件不存在,我该如何解决?恳请赐教,万分感激!代码如下:
unit SearchFile;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Button1: TButton;
Label2: TLabel;
Button2: TButton;
Button3: TButton;
procedure FormCreate(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
label2.Caption :='';
form1.Caption :='文件查询系统';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
pc1,pc2:string;
begin
if Edit1.Text <>'' then
begin
pc1:=Edit1.Text ;
if FileExists(pc1) then
begin
pc2:=ExtractFileName(pc1);
label2.Caption :=pc1+'在'+pc2;
end
else
messagedlg('文件:'+'('+pc1+')'+'不存在',mtError,[mbOK],0);
Edit1.Text :='';
end;
end;
end.
我编写了一个查询文件的小程序,但不管文件是否存在执行的结果都是文件不存在,我该如何解决?恳请赐教,万分感激!代码如下:
unit SearchFile;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Button1: TButton;
Label2: TLabel;
Button2: TButton;
Button3: TButton;
procedure FormCreate(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
label2.Caption :='';
form1.Caption :='文件查询系统';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
pc1,pc2:string;
begin
if Edit1.Text <>'' then
begin
pc1:=Edit1.Text ;
if FileExists(pc1) then
begin
pc2:=ExtractFileName(pc1);
label2.Caption :=pc1+'在'+pc2;
end
else
messagedlg('文件:'+'('+pc1+')'+'不存在',mtError,[mbOK],0);
Edit1.Text :='';
end;
end;
end.