Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Counting files with a given extension??

Posted on 2004-09-25
1
Medium Priority
?
394 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Loops Section Overview

610 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