展开全部
很简单,主要用到 RenameFile 函数。
具体代码:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
SelectDirectoryDialog1: TSelectDirectoryDialog;
procedure Button1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var
sSelDir: string;
begin
if SelectDirectoryDialog1.Execute then
begin
sSelDir := SelectDirectoryDialog1.FileName;
memo1.Append('原目录:' + sSelDir);
if RenameFile(sSelDir, sSelDir + 'aaa') = true then
memo1.Append('更改后目录:' + sSelDir + 'aaa')
else
memo1.Append('更改失败');
end;
end;
end.
操作截屏:
开发环境:
这里上传不了附件,请到我的主页下载:csdn上bq_cui的博客
追问
首先谢谢你的回答,我想用命令直接修改,不用控件,可以吗?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询