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
210 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
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
ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

770 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