vikasgkutty
asked on
find the number of files in a directory? -
Hi,
I have the path of a directory in a CString variable called sNewFolder.
I need to find the total number of files in this directory.
and just messagebox it out.
I think i have to use CFileFind. Any suggetions.
I have the path of a directory in a CString variable called sNewFolder.
I need to find the total number of files in this directory.
and just messagebox it out.
I think i have to use CFileFind. Any suggetions.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
try this
//////////////////////////
CFileFind objFile;
int counter = 0 ;
BOOL bl;
CString szCounter;
CString filename;
::SetCurrentDirectory(sNew
bl = objFile.FindFile(NULL,0);
while(bl)
{
bl = objFile.FindNextFile();
if(!(objFile.IsDirectory()
{
filename = objFile.GetFileName();
counter = counter + 1;
//AfxMessageBox(filename);
}
}
szCounter.Format("Total %d files ",counter);
AfxMessageBox(szCounter);
//////////////////////////
hope this helps
thank u
kiranvj