List of files in a directory?
Hi all,
Is there a function in Visual C++ (6.0) that will return the list of files in a directory?
Thank you,
John
You need to look up three specific Win32 functions: FindFirstFile, FindNextFile and FileClose. FindFirstFile takes the directory name and a WIN32_FIND_DATA structure, and returns a file handle to the directory. You can use a do while loop, with FindNextFile as the condition, to loop through all the directories and files in the directory, and use the contents of the WIN32_FIND_DATA structure each time to determine if what''s found is a directory or a file, it''s name, creation date, and other details. Simply call FileClose with the handle to finish reading that directory.
The argument you specify to FindFirstFile also specifies the file type to search for, eg. "c:\\mydir\\*.*", or "c:\\mydir\\*.txt". If you need any more info, drop a post here...
Insert [CENSORED] here.
The argument you specify to FindFirstFile also specifies the file type to search for, eg. "c:\\mydir\\*.*", or "c:\\mydir\\*.txt". If you need any more info, drop a post here...
Insert [CENSORED] here.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement