我昨天根据课本的提示编了个改文件的后缀的程序,编完后能正常运行,但去查看修改后的文件后缀还是没改变,这是为什么??请高手们帮个忙看下,小弟在这先谢谢各位了。程序的代码如下:
unit gkzhm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
OpenDialog1: TOpenDialog;
Button2: TButton;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if (opendialog1.Execute) then
edit1.Text:=opendialog1.FileName;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
str1:string;
begin
if(trim(edit1.text)<>'') then
begin
str1:=copy(trim(edit2.Text),0,1);
if (str1='.') then
showmessage('修改扩展名后文件如下:'+
changefileExt(edit1.Text,trim(edit2.text)))
else
showmessage('修改扩展名后文件如下:'+
changefileExt(edit1.Text,'.'+trim(edit2.text)))
end
else
showmessage('请输入正确的文件名.')
end;
end.