Re: Getting list of files in a directory
I just posted this for another question, but this might help you as well.
http://www.codeproject.com/file/CFileFindEx.asp
Tom
"Dipali" <Dipali@discussions.microsoft.com> wrote in message
news:0D6E84F4-F2BA-43EC-B1F5-945C66F136A6@microsoft.com...
Hi everyone,
I'm trying to write a routine that will enable me to find all files
matching a wildcard in a specified directory- in the example below, it
should return all files ending with .bmp in the C:\Logos\ directory -
however, the fd.cFileName is blank - whats wrong?
Thanks for your help
Paul
------------
WIN32_FIND_DATA fd;
HANDLE hDir;
char * filePath = "C:\\Logos\\";
char * bitmapWildcard = "*.bmp";
strcpy( filePath, bitmapWildcard); \\ Look for C:\Logos\*.bmp
hDir = FindFirstFile(bitmapWildcard, &fd);
do
{
char * fileName = fd.cFileName;
char * fullPath = strcpy ( filePath, fileName);
CString FileName( fileName ); // This will be things like
mojo_bankrupt.bmp etc.
CString truncatedFileName = FileName.Left( FileName.Find(".") );
// This will be just mojo_bankrupt- which is what we
want
//(no preceding path, and no trailing .bmp
// Other code snipped
} while ( FindNextFile (hDir, &fd) );
FindClose( hDir );