tags:

views:

299

answers:

4

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.

+1  A: 

Use FindFirstFile()/FindNextFile() functions and a recursive algorithm to traverse subfolders.

sharptooth
+3  A: 

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.

John T
FindFirst/NextFile will already tell you the attributes of the file; not need to call GetFileAttributes.
Rob Kennedy
A: 

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.

Alphaneo
+1  A: 
aaron