Solved

executing an algoritm on al files in a directory

Posted on 2002-05-16
4
187 Views
Last Modified: 2010-04-02
Hi, I´m working on my final project to achieve my diplome in electronical engineering. I have written two algoritms in c++ visual and now I have to write the main-file so that I just have to give the directory in which all the pictures on wich the algoritm has to be applied, are. These means that I'm looking for a function, almost like fstream, that counts the number of the pictures that are in the directory, and than I can with a for lus apply the algoritm on all these pictures. I hope this exists in c++, and I hope that some of you can help me, because I'm almost out of time.
0
Comment
Question by:Timen
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
cookre earned 50 total points
ID: 7014011
It sure sound like what you need are FindFirstFile() and FindNextFile() [or _findfirst and _findnext].
0
 
LVL 22

Expert Comment

by:cookre
ID: 7014040
Here's a sample extracted from working code (with lots of extraneous stuff removed)




BOOL             bRC;
WIN32_FIND_DATA  FindData;
HANDLE           FindH;
char             TempStr[256];
char             FromFile[256];
char             ToFile[256];

strcpy(TempStr,NSEDir);
strcat(TempStr,"*.*");
FindH=FindFirstFile(TempStr,&FindData);
if (FindH!=INVALID_HANDLE_VALUE)
   {
   bRC=TRUE;
   while (bRC)
         {
         // Skip directories
         if (!(FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
            {
            ...stuff
            }
         bRC=FindNextFile(FindH,&FindData);
         }
   FindClose(FindH);
   }
return;
}

0
 
LVL 11

Expert Comment

by:griessh
ID: 7178765
Dear Timen

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "cookre"

comment(s) as an answer.

If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points. The link to the Community Support area is: http://www.experts-exchange.com/commspt/


PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 7199786
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

919 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now