DELPHI 新建文件 复制文件 重命名文件名时 文件存在自动重命名


本文整理自网络,侵删。

 

procedure TForm1.Button1Click(Sender: TObject);

var

  Dir, FileTitle, FileExt: string;

  s,s1: string;

  j:Integer;

begin

  Dir := 'C:\';

  FileTitle := '新建 文本文档';

  FileExt := '.txt';

  s1:=Dir+FileTitle+FileExt;


  j:=2;

  if FileExists(s1)  then  //C:\新建 文本文档.txt

  begin

    s:=Format('%s%s(%d)%s', [dir, FileTitle, j, FileExt]);

    while FileExists(s) do

    begin

        Inc(j);

        s := Format('%s%s(%d)%s', [dir, FileTitle, j, FileExt]);

    end;


    if not FileExists(s) then Memo1.Lines.SaveToFile(s);

    end

  else

     Memo1.Lines.SaveToFile(s1);

end;


https://www.cnblogs.com/xe2011/p/3384241.html

相关阅读 >>

Delphi代码,直截注入别的进程,之后直截运行在别的进程中的代码

Delphi中sendmessage给一个edit控件发送wm_settext消息

Delphi dateof、timeof、yearof、monthof、weekof、dayof、hourof、minuteof、secondof、millisecondof �c 提取时间成分

Delphi自动以管理员身份在vista 和 windows7 下运行程序

Delphi 不用控件用函数实现发email

Delphi xe 取得 app 自己的版本号 (狠跨 4 个平台)

Delphi常用日期函数

Delphi ansiendstext 用法之一(路径结尾自动加\)

Delphi base32 的加密和解密

Delphi 校验手机号及身份证号

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...