//Get size of a whole dir
//return bytes
DWORD64 GetFolderSize(LPCTSTR szPath, DWORD *dwFiles, DWord *dwFolders)
{
TCHAR szFileFilter[512];
TCHAR szFilePath[512];
HANDLE hFind = NULL;
WIN32_FIND_DATA fileinfo;
DWord64 dwSize = 0;
strcpy(szFilePath,szPath);
strcat(szFilePath,"\");
strcpy(szFileFilter,szFilePath);
strcat(szFileFilter,"*.*");
hFind = FindFirstFile(szFileFilter,&fileinfo);
do
{
if(fileinfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
if (!strcmp(fileinfo.cFileName,".") || !strcmp(fileinfo.cFileName,".."))
{
//Do nothing for "." and ".." folders
}
else
{
TCHAR sztmp[512];
strcpy(sztmp,szFilePath);
strcat(sztmp,fileinfo.cFileName);
dwSize = dwSize + GetFolderSize(sztmp);
if(dwFolders != NULL)
{
++(*dwFolders);
}
}
}
else
{
if(dwFiles != NULL)
{
++(*dwFiles);
}
}
dwSize += fileinfo.nFileSizeLow;
}while(FindNextFile(hFind,&fileinfo));
FindClose(hFind);
return dwSize;
}