cch8080 发表于 2007-9-13 07:06

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

<P>    我昨天根据课本的提示编了个改文件的后缀的程序,编完后能正常运行,但去查看修改后的文件后缀还是没改变,这是为什么??请高手们帮个忙看下,小弟在这先谢谢各位了。程序的代码如下:<BR>    unit gkzhm;</P>
<P>interface</P>
<P>uses<BR>  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<BR>  Dialogs, StdCtrls;</P>
<P>type<BR>  TForm1 = class(TForm)<BR>    Label1: TLabel;<BR>    Edit1: TEdit;<BR>    Edit2: TEdit;<BR>    Button1: TButton;<BR>    OpenDialog1: TOpenDialog;<BR>    Button2: TButton;<BR>    Label2: TLabel;<BR>    procedure Button1Click(Sender: TObject);<BR>    procedure Button2Click(Sender: TObject);<BR>  private<BR>    { Private declarations }<BR>  public<BR>    { Public declarations }<BR>  end;</P>
<P>var<BR>  Form1: TForm1;</P>
<P>implementation</P>
<P>{$R *.dfm}</P>

<P>procedure TForm1.Button1Click(Sender: TObject);<BR>begin<BR> if (opendialog1.Execute) then<BR>   edit1.Text:=opendialog1.FileName;<BR>end;</P>
<P>procedure TForm1.Button2Click(Sender: TObject);<BR> var<BR>   str1:string;<BR>begin<BR>  if(trim(edit1.text)&lt;&gt;'') then<BR>    begin<BR>      str1:=copy(trim(edit2.Text),0,1);<BR>      if (str1='.') then<BR>        showmessage('修改扩展名后文件如下:'+<BR>        changefileExt(edit1.Text,trim(edit2.text)))<BR>      else<BR>        showmessage('修改扩展名后文件如下:'+<BR>        changefileExt(edit1.Text,'.'+trim(edit2.text)))<BR>    end<BR>  else<BR>     showmessage('请输入正确的文件名.')<BR>    <BR>end;</P>
<P>end.</P>

anthony634 发表于 2007-9-13 22:25

看帮助ChangeFileExt does not rename the actual file, it just creates a new file name string. 可以用 renamefile
[align=right][color=#000066][此贴子已经被作者于2007-9-13 22:27:10编辑过][/color][/align]


页: [1]

编程论坛