注册 登录
编程论坛 Delphi论坛

[求助]关于改后缀的问题

cch8080 发布于 2007-09-13 07:06, 863 次点击

我昨天根据课本的提示编了个改文件的后缀的程序,编完后能正常运行,但去查看修改后的文件后缀还是没改变,这是为什么??请高手们帮个忙看下,小弟在这先谢谢各位了。程序的代码如下:
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.

1 回复
#2
anthony6342007-09-13 22:25
看帮助ChangeFileExt does not rename the actual file, it just creates a new file name string. 可以用 renamefile

[此贴子已经被作者于2007-9-13 22:27:10编辑过]


1