[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 185
  • Last Modified:

Files in Library MFC

Hi,
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.
0
dani333
Asked:
dani333
1 Solution
 
AlexFMCommented:
See FindFirstFile, FindNextFile.
0
 
PriyeshCommented:
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())
         continue;

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

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

   finder.Close();
}
0
 
dani333Author Commented:
Thanks again:-)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now