![](https://i-blog.csdnimg.cn/blog_migrate/48c5421c68b32a129538968634866012.gif)
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;
附件列表