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
207 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 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.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

757 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