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
Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号
执行时间: 0.033984899520874 seconds