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 怎样判断spinedit在微调时值是增加还是减少了

Delphi 固定保持datetime日期格式

Delphi memo 字符串换行

Delphi获取进程pid

Delphi xe6 android拨号函数

Delphi setformfullscreen()窗体全屏显示

Delphi 使用钩子函数建立一个全局的鼠标钩子

Delphi中stringgrid删除行

Delphi android控制睡眠

Delphi shellexecute多种用法

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



打赏

取消

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

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

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

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

评论

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