What OS are you on? There are the opendir/readdir/closedir family of functions for one.