Hi Everyone,
I wonder if someone might be able to help on an iteration issue. I have a directory of files all of which will have constant values and a numeric variable as their file name (e.g. file1.txt, file2.txt, file3.txt). this directory is written to as part of an indexing process.
What I need to do is write a bit of code that looks through that directory and establishes what the next sequence number will be. Using the example above, the next sequence number will be 4. (file4.txt).
I'm having a bit of a brain freeze and cant think how I can do this. Can anyone help?
Many thanks
Loading
VulpesPosted Apr 19, 2011, 5:43 AM
VulpesPosted Apr 19, 2011, 6:11 AM
If you had 10 or more files, then it might not return them in sequence even if you sorted them first. This is because file10.txt would sort after file1.txt but before file2.txt. So, I wouldn't depend on the files being returned in any particular order.
iainPosted Apr 19, 2011, 5:59 AM
All i had to add was Max++ under int num; and it returned the max file sequence perfectly :-)
Thanks ever so much!