Hi,
I was wondering if anyone has encountered this problem. I'm using Win32 API calls FirstFile() and FindNextFile() to search for files on my computer. The problem is, both function calls seem to return extra files that aren't part of my search string. Has anyone else experienced the same problem?
I wrote a C/C++ console program that prompts for a Search String and a Search Path.
To recreate this problem, I enter "bc" as the search string (without the quotes) then enter the search path as "C:\" .. again, without the quotes but the backslash is required.
The program will start by gathering all directories and subdirectories that exist on the computer then search for files in each directory that contain the search string by passing C:\*bc* to FindFirstFile(). The program attaches the asterisks at the beginning and end of the Search String.
FindFirstFile and FindNextFile returns many files that contain the letters "bc", "bC", "Bc", and "BC". The problem is, these function calls will also return a few files that don't contain the letter "bc","BC","bC", or "Bc".
I've attached the source code.
If you'd like to run this code to see what I'm jabbering about, just be aware that it generates a file called findfile.dat. I use this file as an aid to debugging and contains the list of all files found. For files where there is an incorrect match, I print BAD MATCH.... It flags a BAD MATCH for files that contain "BC","bC", or "Bc" so ignore those. But it will also flag a BAD MATCH for files that don't contain these letters and also indicate which function call found that file, either FindFirstFile() or FindNextFile().
bronzefury