lazarus:一个函数修改目录名(文件夹名)

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.

你可能感兴趣的:(修改,目录名,文件夹名,Lazarus)