How do I save a file to a name that doesnt exist in the folder?
Posted on 2004-04-15
1. Save a file to a folder.
2. Check to see if the file exists.
3. If it does, append a sequential number to the file name.
4. Check to see if that file exists.
5. If it does, increment the sequential number to the file name.
Loop this process until a file name does not exist in the folder.
contents of c:\temp --> test.txt test1.txt test2.txt
save test.txt in c:\temp
does test.txt exist? Yes, rename to test1.txt
does test1.txt exist? Yes, rename to test2.txt
does test2.txt exist? Yes, rename to test3.txt
does test3.tst exist? no, save as test3.txt