本文整理自网络,侵删。

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 xe 取得 app 自己的版本号 (狠跨 4 个平台)
Delphi ansiendstext 用法之一(路径结尾自动加\)
更多相关阅读请进入《Delphi》频道 >>