Use CFileFind
CFileFind filefind;
CString strPath="C:\\";//Indicates the address of the folder to be searched
CString strDoc="*.*";//Indicates the type of file suffix to be searched
CString strFind=strPath+strDoc;
int nFind=0;
BOOL bworking=filefind.FindFile(strFind);
while(bworking)
{
bworking=filefind,FindNextFile(strFind);
if(!filefind.IsDots() && !filefind.IsDirectory())//not "." not ".." and not a folder
{
nFind++;
{
}
The final number of nFind is the number of files found.