Skip to content

Latest commit

 

History

History
197 lines (151 loc) · 5.41 KB

nf-fileapi-getfilesize.md

File metadata and controls

197 lines (151 loc) · 5.41 KB
UIDtitledescriptionhelpviewer_keywordsold-locationtech.rootms.assetidms.datems.keywordsreq.headerreq.include-headerreq.target-typereq.target-min-winverclntreq.target-min-winversvrreq.kmdf-verreq.umdf-verreq.ddi-compliancereq.unicode-ansireq.idlreq.max-supportreq.namespacereq.assemblyreq.type-libraryreq.libreq.dllreq.irqltargetosreq.typenamesreq.redistms.customf1_keywordsdev_langstopic_typeapi_typeapi_locationapi_name
NF:fileapi.GetFileSize
GetFileSize function (fileapi.h)
Retrieves the size of the specified file, in bytes.
GetFileSize
GetFileSize function [Files]
_win32_getfilesize
base.getfilesize
fileapi/GetFileSize
fs.getfilesize
winbase/GetFileSize
fs\getfilesize.htm
fs
3f5d2e4a-1e05-41c0-9b7e-0155e212f6dd
12/05/2018
GetFileSize, GetFileSize function [Files], _win32_getfilesize, base.getfilesize, fileapi/GetFileSize, fs.getfilesize, winbase/GetFileSize
fileapi.h
Windows.h
Windows
Windows XP [desktop apps only]
Windows Server 2003 [desktop apps only]
Kernel32.lib
Kernel32.dll
Windows
19H1
GetFileSize
fileapi/GetFileSize
c++
APIRef
kbSyntax
DllExport
Kernel32.dll
API-MS-Win-Core-File-l1-1-0.dll
KernelBase.dll
API-MS-Win-Core-File-l1-2-0.dll
API-MS-Win-Core-File-l1-2-1.dll
API-MS-Win-Core-File-l1-2-2.dll
API-MS-Win-DownLevel-Kernel32-l1-1-0.dll
MinKernelBase.dll
GetFileSize

GetFileSize function

-description

Retrieves the size of the specified file, in bytes.

It is recommended that you use GetFileSizeEx.

-parameters

-param hFile [in]

A handle to the file.

-param lpFileSizeHigh [out, optional]

A pointer to the variable where the high-order doubleword of the file size is returned. This parameter can be NULL if the application does not require the high-order doubleword.

-returns

If the function succeeds, the return value is the low-order doubleword of the file size, and, if lpFileSizeHigh is non-NULL, the function puts the high-order doubleword of the file size into the variable pointed to by that parameter.

If the function fails and lpFileSizeHigh is NULL, the return value is INVALID_FILE_SIZE. To get extended error information, call GetLastError. When lpFileSizeHigh is NULL, the results returned for large files are ambiguous, and you will not be able to determine the actual size of the file. It is recommended that you use GetFileSizeEx instead.

If the function fails and lpFileSizeHigh is non-NULL, the return value is INVALID_FILE_SIZE and GetLastError will return a value other than NO_ERROR.

-remarks

You cannot use the GetFileSize function with a handle of a nonseeking device such as a pipe or a communications device. To determine the file type for hFile, use the GetFileType function.

The GetFileSize function retrieves the uncompressed size of a file. Use the GetCompressedFileSize function to obtain the compressed size of a file.

Note that if the return value is INVALID_FILE_SIZE (0xffffffff), an application must call GetLastError to determine whether the function has succeeded or failed. The reason the function may appear to fail when it has not is that lpFileSizeHigh could be non-NULL or the file size could be 0xffffffff. In this case, GetLastError will return NO_ERROR (0) upon success. Because of this behavior, it is recommended that you use GetFileSizeEx instead.

Transacted Operations:  If there is a transaction bound to the file handle, then the function returns information for the isolated file view.

In Windows 8 and Windows Server 2012, this function is supported by the following technologies.

TechnologySupported
Server Message Block (SMB) 3.0 protocol Yes
SMB 3.0 Transparent Failover (TFO) Yes
SMB 3.0 with Scale-out File Shares (SO) Yes
Cluster Shared Volume File System (CsvFS) Yes
Resilient File System (ReFS) Yes
 

Examples

For an example, see Creating a View Within a File.

-see-also

File Management Functions

GetCompressedFileSize

GetFileSizeEx

GetFileType

close