Googling around shows that you could do something like this via system():
I believe for *nix systems, the following should work:
system("dir directory >> files.txt ");
directory would have to be replaced with whatever directory you want to search through. After executing this, the output of the command (including the file list) would be placed inside a file named files.txt.
system("ls directory >> files.txt ");
Otherwise, I believe you would have to find the O/S specific system calls to get the information you want, such as what Sentral posted.