personally, I'd use boost::filesystem

if you cant, then this looks like it will work
http://john.nachtimwald.com/2010/06/...-its-contents/