GetFileSizeEx
The GetFileSizeEx function retrieves the size of a specified file.
Syntax
BOOL GetFileSizeEx(
HANDLE hFile,
PLARGE_INTEGER lpFileSize
);
Parameters
| Parameter | Type | Description |
|---|---|---|
hFile |
HANDLE |
A handle to the file for which the size is to be retrieved. The handle must have been created with the GENERIC_READ or GENERIC_WRITE access right. |
lpFileSize |
PLARGE_INTEGER |
A pointer to a LARGE_INTEGER structure that receives the file size in bytes. |
Return Value
If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
The GetFileSizeEx function is the recommended way to retrieve the size of a file because it can handle files larger than 2 gigabytes (GB).
To get the size of a file before the file is opened, you can use the CreateFile function with the OPEN_EXISTING flag and then call GetFileSizeEx.
Note: For backward compatibility, the GetFileSize function is also available. However, it cannot correctly report file sizes larger than 4 GB on 32-bit systems.
Requirements
Minimum supported client: Windows XP Professional [desktop apps | UWP apps]
Minimum supported server: Windows Server 2003 [desktop apps | UWP apps]
Header: fileapi.h
Library: Kernel32.lib
DLL: Kernel32.dll