Sign in to follow this  

Searching a folder

This topic is 4819 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, i was just wondering is there a function or something that tells you what files are in a folder. So instead of having to type in a file for loading into the source. My program will search the data folder and load all of the files that are in it. Thx

Share this post


Link to post
Share on other sites
Its simple, check out FindFirstFile and FindNextFile.

Heres some code:
WIN32_FIND_DATA		FileData;
HANDLE hFile;
String found;

hFile = FindFirstFile("Data\\*.bmp", &FileData);
if ( INVALID_HANDLE_VALUE == hFile ) { return false; };
found = FileData.cFileName;

//To find out if a returned file name is in fact a folder do:
bool isFolder = (FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);

// To find the next file do:
if ( 0 == FindNextFile(hFile, &FileData ) ) { return false; };

// Now its just a question of looping


Hope it helped...

Share this post


Link to post
Share on other sites

This topic is 4819 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this