My approach is to append a suffix letter to the MONDDYY name base, and then
display the candidate name in an edit box, in case the user wants to change
it. The code is ridiculously simple:
Name := LeftStr (MonDDYY_HHMMSS (Now), 7);
Suffix := 'A';
While FileExists (EdFolder.Text + '\' + Name + Suffix + '.zip') and
(Suffix [1] in ['A'..'Z']) do
inc (Suffix [1]);
if not (Suffix [1] in ['A'..'Z']) then
Suffix := '';
EdFileName.Text := Name + Suffix;
Then, in the zip creating part, I simply enclose the whole thing in a try
... block
try
with Zip do begin // ZipForge
FName := EdFolder.Text + '\' + EdFileName.Text + '.zip';
FileName := Fname;
OpenArchive (fmCreate);
BaseDir := 'C:\WinACS\ACSData';
Password := Pwd;
AddFiles ('*.*');
CloseArchive;
end;
.....
If something goes wrong, I inform the user, and let him change the name and
try again. The only way it will get in trouble anyway is if he/she tries to
make more than 26 backups in one day, or he/she changes the name to
something already used.
Rainer
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi