in reply to How to read only limited number of files from a Directory

See opendir and readdir.