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 xe 打开andorid gps设置

Delphi windows 编程[12] - 菜单与菜单资源(1-3)

Delphi mediaplayer android 下播放 mp4 的问题

Delphi 每年、月、周、日的开始与结束的时间startofayear … startoftheyear … endofayear … endoftheyear

Delphi中显示gif动画

Delphi 获取北京时间

Delphi 编写系统服务

Delphi 判断端口是否被使用

Delphi xe6 for android 让手机震动

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



打赏

取消

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

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

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

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

评论

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