How would one search for files on a computer? Maybe looking for certain extensions.
I need to iterate through all the files and examine file names.
Say I wanted to find all files with an .code extension.
How would one search for files on a computer? Maybe looking for certain extensions.
I need to iterate through all the files and examine file names.
Say I wanted to find all files with an .code extension.
Use FindFirstFile()/FindNextFile() functions and a recursive algorithm to traverse subfolders.
For Windows, you would want to look into the FindFirstFile() and FindNextFile() functions. If you want to implement a recursive search, you can use GetFileAttributes() to check for FILE_ATTRIBUTE_DIRECTORY
. If the file is actually a directory, continue into it with your search.
FindFirstFile()/ FindNextFile() will do the job in finding the list of files in the directory. To do recursive search through the sub-directories you might use _splitpath
to split the path, into directory and filenames, and then use the resulting directory detail to do a recursive directory search.