Originally Posted by
grumpy
In C++, the approach to do this is specific to the operating system.
If doing this under windows, look up the functions FindFirstFile() and FindNextFile() in the win32 API.
Under most (I'd hesitate to say all) flavours of unix, look up the functions findfirst() and findnext().
You might also try the boost filesystem library (look up the directory_iterator class). There are trade-offs with using that library, but it does aim for portability - and is/was the basis for a proposal to include such functionality in a future C++ standard (I'm not sure of the status of that, offhand - I seem to recall some concerns with an "illusion of portability" in discussion).