Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
216 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
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 750 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

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!

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

722 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