GetFileSizeEx

The GetFileSizeEx function retrieves the allocated size of a specified file.

BOOL GetFileSizeEx( HANDLE hFile, PLARGE_INTEGER lpFileSize );

Parameters

hFile
A handle to the file. The handle must have been created with the GENERIC_READ access right.
lpFileSize
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

This function is a replacement for the GetFileSize function. It supports files larger than 4 gigabytes (GB).

The allocated size of a file is the size of the region of the disk that contains data for the file. This value may be greater than the actual size of the file. For example, if a file has a size of 100 bytes and the last byte is at offset 100, the allocated size might be 4096 bytes if the file system allocates space in 4096-byte clusters.

Requirements

Minimum supported client Windows Vista
Minimum supported server Windows Server 2008
Header fileapi.h (include windows.h)
Library Kernel32.lib
DLL Kernel32.dll

See also

Note

This documentation is for illustrative purposes and may not reflect the most current or complete information available on the official Microsoft Developer Network (MSDN).