Get file size
-
I am trying to get the file size, with code:
::FindFirstFile((LPCTSTR)strFileSpec, &fd);
LARGE_INTEGER size;
size.HighPart = fd.nFileSizeHigh;
size.LowPart = fd.nFileSizeLow;
DWORD dwsize = (DWORD)size.QuadPart;but is not right when the size of the file is huge, because at a file with 7.8 GB in windows explorer, my code says that has 3.03 GB ... I have tried with this code too:
CFileStatus status; CFile::GetStatus(strFileName, status); DWORD dwsize = (DWORD)status.m\_size);
the same result ... what I am doing wrong ? My OS is Win10 64 bit.
-
I am trying to get the file size, with code:
::FindFirstFile((LPCTSTR)strFileSpec, &fd);
LARGE_INTEGER size;
size.HighPart = fd.nFileSizeHigh;
size.LowPart = fd.nFileSizeLow;
DWORD dwsize = (DWORD)size.QuadPart;but is not right when the size of the file is huge, because at a file with 7.8 GB in windows explorer, my code says that has 3.03 GB ... I have tried with this code too:
CFileStatus status; CFile::GetStatus(strFileName, status); DWORD dwsize = (DWORD)status.m\_size);
the same result ... what I am doing wrong ? My OS is Win10 64 bit.
Quote:
the same result ... what I am doing wrong ?
Using a
DWORD
(dwsize
) for storing the value. The size of such 'huge files' simply doesn't fit in aDWORD
(it is 32-bit wide, see Windows Data Types - Windows applications | Microsoft Docs[^]). Use a 64-bit data type (likeDWORD64
orDWORDLONG
). -
Quote:
the same result ... what I am doing wrong ?
Using a
DWORD
(dwsize
) for storing the value. The size of such 'huge files' simply doesn't fit in aDWORD
(it is 32-bit wide, see Windows Data Types - Windows applications | Microsoft Docs[^]). Use a 64-bit data type (likeDWORD64
orDWORDLONG
).