Solved

Process 50 files in one folder a file at a time thru a dialog editbox using VC++ 6.0

Posted on 2002-03-12
6
212 Views
Last Modified: 2010-04-01
I wrote a program to process a file at a time thru the edit box by selecting the file from the folder.  Now I need to modify the program so that I can process up to 60 files in a directory and run them thru the program that I wrote using VC++ 6.0 or by using wildcards for the file names.  Is there a way that I can do this? and if there is could your provide the sample code to do this?  
0
Comment
Question by:adatd
[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
6 Comments
 
LVL 30

Expert Comment

by:Axter
ID: 6858866
What type of program do you write? (Dialog based, Doc/View, Console)

>>Is there a way that I can do this?
Yes.

>>and if there is could your provide the sample code to do
>>this?  

What method do you prefer?  Do you want the user to select the files from a Common dialog?
Or do you want the wildcard approach?
0
 
LVL 6

Expert Comment

by:thienpnguyen
ID: 6858883
You can use _findfirst, _findnext ...

* FFIND.C: This program uses the 32-bit _find functions to print
 * a list of all files (and their attributes) with a .C extension
 * in the current directory.
 */

#include <stdio.h>
#include <io.h>
#include <time.h>

void main( void )
{
    struct _finddata_t c_file;
    long hFile;

    /* Find first .c file in current directory */
    if( (hFile = _findfirst( "*.c", &c_file )) == -1L )
       printf( "No *.c files in current directory!\n" );
   else
   {
            printf( "Listing of .c files\n\n" );
            printf( "\nRDO HID SYS ARC  FILE         DATE %25c SIZE\n", ' ' );
            printf( "--- --- --- ---  ----         ---- %25c ----\n", ' ' );
            printf( ( c_file.attrib & _A_RDONLY ) ? " Y  " : " N  " );
            printf( ( c_file.attrib & _A_SYSTEM ) ? " Y  " : " N  " );
            printf( ( c_file.attrib & _A_HIDDEN ) ? " Y  " : " N  " );
            printf( ( c_file.attrib & _A_ARCH )   ? " Y  " : " N  " );
            printf( " %-12s %.24s  %9ld\n",
               c_file.name, ctime( &( c_file.time_write ) ), c_file.size );

            /* Find the rest of the .c files */
            while( _findnext( hFile, &c_file ) == 0 )
            {
                printf( ( c_file.attrib & _A_RDONLY ) ? " Y  " : " N  " );
                printf( ( c_file.attrib & _A_SYSTEM ) ? " Y  " : " N  " );
                printf( ( c_file.attrib & _A_HIDDEN ) ? " Y  " : " N  " );
                printf( ( c_file.attrib & _A_ARCH )   ? " Y  " : " N  " );
                printf( " %-12s %.24s  %9ld\n",
                   c_file.name, ctime( &( c_file.time_write ) ), c_file.size );
            }

       _findclose( hFile );
   }
}

0
 
LVL 6

Expert Comment

by:thienpnguyen
ID: 6858897
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Accepted Solution

by:
pagladasu earned 250 total points
ID: 6858935
WIN32_FIND_DATA filedata;
char *filename;
HANDLE handle=FindFirstFile("*.txt",&filedata);
if handle{
  do{
    filename = filedata.cFileName;
    //call your processing routine for filename here
    BOOL ret=FindNextFile(handle,&filedata);
  }while(ret);
}
0
 

Author Comment

by:adatd
ID: 6859949
It is a a Dialog based program and I would rather use the wildcard approach by entering the directory in the edit box ie...   "c:\morethings\jackson\*.050"

that way it can go to that directory and process all the files in it that match the .050 extension.
0
 
LVL 3

Expert Comment

by:ruff_ryder
ID: 6860601
Use a common dialog as Axter suggested. With the Common dialog you can apply the filter where only files with a specific extension will be shown in the File Open Dialog that is displayed.

This way users can choose from only files with the .050 extension you specify.

Have a look at the CFileDialog class in the MSDN docs.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using Diagnostic tools in VS2015: Unresoved allocations 19 141
White board coding practice 3 98
c++ reading data from file into two dimensional array 3 146
visual C++ 1 37
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

738 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