Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3021

files in a directory

$
0
0
Hello,

Thanks for taking the time to help. I'm trying to just list the files in a directory. I've looked at some examples I don't know why this isn't working.

Code:

struct _finddata_t        directoriesData;                               
long                fileListing;                       

if ( (fileListing = _findfirst((folderName).c_str(), &directoriesData)) == -1L)
{
        log("\tError while processing directory structure\n");                                       
}
do
{                                       
        string fileSpec;
        fileSpec = "*.lpt";
        if (PathMatchSpec(directoriesData.name, fileSpec.c_str()))
        {
                string name = folderName + directoriesData.name;
                inputData->filesList.push_back(name.c_str());
        }                                       
}while (_findnext(fileListing, &directoriesData) == 0);

Never goes through the do-while loop more than once and there are 4 files in the folder. Again, thanks for the help.

Greg

Viewing all articles
Browse latest Browse all 3021