I'm having trouble finding any information on how to get a list of files or filenames (preferably with specific extensions) from a given directory, not using MFC.
Any help appreciated...
Any help appreciated...
A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.
WIN32_FIND_DATA fd;//structure to contain returned file info
HANDLE hFind;//file handle returned
// count the files to see how many, to size the box
TCHAR fullpath[MAX_PATH];
int pathlen = PocketPC::GetFullPathName(_T("A"),fullpath);
fullpath[pathlen-1]=0;//chop off the 'A' needed for fullpath func to work?
_tcscat(fullpath,TEXT("*.sav"));
int file_cnt=0;
hFind = FindFirstFile(fullpath, &fd);//TEST find first file of type *.sav
if (hFind != INVALID_HANDLE_VALUE)//if we found one
{
text_y+=16;//move down
file_cnt++;
}
for(int z=0;z<20;z++){//find up to a further 99 files
if(FindNextFile(hFind, &fd))// next file
{
file_cnt++;
if(z<9)
{
text_y+=16;//move down
}
}//end if
}//end for
FindClose(hFind);// stop finding files
WIN32_FIND_DATA fd;
HANDLE hFind = FindFirstFile(_T("\\*.*"), &fd;);
if (hFind != INVALID_HANDLE_VALUE) {
do {
//Do stuff with fd here
} while (FindNextFile(hFind, &fd;);
FindClose(hFind);
}