I am trying to obtain the size of a directory on disk as displayed in the Properties of a folder.
Using
FindFirstFile
, I can get the size of each file in the directory but this is less than the size I want. I assume what is missing is the size of the directory file itself (I am not using compression).
FindFirstFile
gives me the attributes, etc. of the directory but the size (both high and low) is zero.
Similarly
GetFileSize
returns zero. MSDN gives
GetFileSize
as one of the functions available on a directory (
http://msdn.microsoft.com/en-us/library/aa365258(VS.85).aspx).
In my simple test below, both
iDLowSize
and
iDHighSize
are returned as zero. If I change the name to being a non-directory (file), the size is returned OK. Apologies but the code is C.
hCreate = CreateFile("c:\\Windows", GENERIC_READ, 0, NULL, OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (hCreate == INVALID_HANDLE_VALUE) {
iDLowSize = GetFileSize(hCreate, &iDHighSize);
CloseHandle(hCreate);
Any help will be appreciated.