?
Solved

Counting files with a given extension??

Posted on 2004-09-25
1
Medium Priority
?
392 Views
Last Modified: 2010-04-24
I am needing to count the files inside a certain directory with a certain filemask (eg: "*.ini")when a given event occurs.  I do not need a recursive search through sub directories

I know I can load each into an array and count them there.  I am wondering if there is a directory* or file* class in c++ .net that would be quicker to execute and code??

Thanks, Jason
0
Comment
Question by:jdhatch
[X]
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
1 Comment
 
LVL 19

Accepted Solution

by:
drichards earned 2000 total points
ID: 12153365
If you are using managed C++, there is a Directory class that has a static method called GetFiles:

    System::String *files[] =  System::IO::Directory::GetFiles(S"C:\", S"*.ini");
    int count = files->Length;
    System::Console::WriteLine(files[0]); // Access the array to get file names.

If you are not using managed C++, you can use CFileFind if you are using MFC or FindFirstFile/FindNextFile (which are how CFileFind is implemented) if you don't want to use MFC.  Are you using managed code?
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

777 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