in reply to How to read contents of directory into an array?

The function you're probably looking for is readdir.