Files in Library MFC

Posted on 2003-02-23
Medium Priority
Last Modified: 2013-11-20
I would like to know how to get the
numbers of files in a given library path,
with a specific extension?
For Example:

m_sPath="D:\curiosity\cool stuff\"
and i would like to know how many files with ".bmp"
extension,are in that library.

Thanks a lot.
Question by:dani333
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 48

Expert Comment

ID: 8003359
See FindFirstFile, FindNextFile.

Accepted Solution

Priyesh earned 200 total points
ID: 8004915
see the CFileFind class in MSDN. the following example is from msdn, modified to find bmp files

void Recurse(LPCTSTR pstr)
   CFileFind finder;

   // build a string with wildcards
   CString strWildcard(pstr);
   strWildcard += _T("\\*.bmp");

   // start working for files
   BOOL bWorking = finder.FindFile(strWildcard);

   while (bWorking)
      bWorking = finder.FindNextFile();

      // skip . and .. files; otherwise, we'd
      // recur infinitely!

      if (finder.IsDots())

      // if it's a directory, recursively search it

      if (finder.IsDirectory())
         CString str = finder.GetFilePath();
         cout << (LPCTSTR) str << endl;


Author Comment

ID: 8052096
Thanks again:-)

Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question