Before you rush off and create an array of 1000's of filenames, you should be aware that most operating systems restrict the number of open files per process.
Eg.
c++ - Is there a limit on number...