944,144 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 4777
  • C++ RSS
May 30th, 2005
0

FindFirstFile & FindNextFile return extra files?

Expand Post »
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, 77 views)
File Type: txt main.cpp.txt (1.1 KB, 87 views)
File Type: txt FileFinder.cpp.txt (8.9 KB, 103 views)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bronzefury is offline Offline
3 posts
since May 2005
Jun 3rd, 2005
0

Re: FindFirstFile & FindNextFile return extra files?

just wondering, was anyone able to recreate this bug?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bronzefury is offline Offline
3 posts
since May 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: conversion
Next Thread in C++ Forum Timeline: need help problem with cin.getline method





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC