FindFirstFile & FindNextFile return extra files?

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2005
Posts: 3
Reputation: bronzefury is an unknown quantity at this point 
Solved Threads: 0
bronzefury's Avatar
bronzefury bronzefury is offline Offline
Newbie Poster

FindFirstFile & FindNextFile return extra files?

 
0
  #1
May 30th, 2005
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
Attached Files
File Type: txt FileFinder.hpp.txt (1.3 KB, 26 views)
File Type: txt main.cpp.txt (1.1 KB, 31 views)
File Type: txt FileFinder.cpp.txt (8.9 KB, 37 views)
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 3
Reputation: bronzefury is an unknown quantity at this point 
Solved Threads: 0
bronzefury's Avatar
bronzefury bronzefury is offline Offline
Newbie Poster

Re: FindFirstFile & FindNextFile return extra files?

 
0
  #2
Jun 3rd, 2005
just wondering, was anyone able to recreate this bug?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC