It looks like you're not processing the results of your FindFirstFile call:
Code:
long CDirectoryInfo::GetDirectorySize(CString path)
{
WIN32_FIND_DATA data;
HANDLE hFind;
CString szCurrentPath = path + "\\*.*";
hFind = FindFirstFile((LPCTSTR)szCurrentPath, &data);
if(hFind == INVALID_HANDLE_VALUE)
{
return -1;
}
if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
(strcmp(data.cFileName, ".") != 0) &&
(strcmp(data.cFileName, "..") != 0))
{
szCurrentPath = path + "\\" + data.cFileName;
GetDirectorySize(szCurrentPath);
}
else
{
if((strcmp(data.cFileName, ".") != 0) && (strcmp(data.cFileName, "..") != 0))
{
m_lDirectorySize += data.nFileSizeHigh * (MAXDWORD + 1) + data.nFileSizeLow;
}
}
do
{
if(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
if((strcmp(data.cFileName, ".") != 0) && (strcmp(data.cFileName, "..") != 0))
{
szCurrentPath = path + "\\" + data.cFileName;
GetDirectorySize(szCurrentPath);
}
}
else
{
m_lDirectorySize += data.nFileSizeHigh * (MAXDWORD + 1) + data.nFileSizeLow;
}
}
while(FindNextFile(hFind, &data));
FindClose(hFind);
return m_lDirectorySize;
}