VC文件夹大小(转)

使用自带的类 CFileFind

finder.FindNextFile();  遍历所有文件,按照修改时间顺序遍历

//参数输入 文件夹路径

//返回文件夹大小 byte

DWORD GetDirSize(CString strDirPath)
{
CString strFilePath;
DWORD dwDirSize = 0;

strFilePath += strDirPath;
strFilePath += "\*.*";

int ret;
CFileFind finder;
FILETIME fileT[100];
BOOL bFind = finder.FindFile(strFilePath);
ret=0;
while (bFind)
{
bFind = finder.FindNextFile();
if (!finder.IsDots())
{
CString strTempPath = finder.GetFilePath();
if (!finder.IsDirectory())
{
dwDirSize += finder.GetLength();
}
else
{
dwDirSize += GetDirSize(strTempPath);
}

}
}
finder.Close();
return dwDirSize;
}

原文地址:https://www.cnblogs.com/LJWJL/p/5523518.html