double
CEvent::GetDirSize(CString strFullPath)
{
double dwDirSize,dwSubDirSize;
CFileFind finder;
dwDirSize=dwSubDirSize=0;
strFullPath+=_T("\\*.*");
if(finder.FindFile(strFullPath))
{
while(1)
{
BOOL bFound;
bFound=finder.FindNextFile();
if (finder.IsDirectory())
{
if (!finder.IsDots())
{
dwSubDirSize=GetDirSize(finder.GetFilePath());
dwDirSize+=dwSubDirSize;
}
}
else
{
CFile file;
if (file.Open(finder.GetFilePath(),CFile::modeRead))
{
dwDirSize+=file.GetLength();
file.Close();
}
}
if(bFound==FALSE)
break;
}
}
finder.Close();
return dwDirSize;
}
本文转自:http://ituike.com/bingling/article.asp?id=121