2.1.10.19 GetFileAttributesEx


Description

Retrieves attributes for a specified file or directory. It is similar to GetFileAttributes, but it returns more information - in addition to attributes, it also returns various file times and file size.

Syntax

BOOL GetFileAttributesEx( LPCSTR lpcszFilename, int nInfoLevel, WIN32_FILE_ATTRIBUTE_DATA * lpFileInfo )

Parameters

lpcszFilename
[input] full pathname of the file
nInfoLevel
[input] must be 0.
lpFileInfo
[output] pointer to the WIN32_FILE_ATTRIBUTE_DATA which will receive the information
about the file:
typedef struct _WIN32_FILE_ATTRIBUTE_DATA {
DWORD dwFileAttributes; // attributes (the same as for the function GetFileAttributes)
FILETIME ftCreationTime; // creation time
FILETIME ftLastAccessTime; // last access time
FILETIME ftLastWriteTime; // last modification time
DWORD nFileSizeHigh; // the high DWORD of the file size (it is zero unless the file is over four gigabytes)
DWORD nFileSizeLow; // the low DWORD of the file size
} WIN32_FILE_ATTRIBUTE_DATA;

Return

Returns FALSE if file sepcified is not a valid file name or directory name

Returns TRUE if succeed

Examples

EX1

int GetFileAttributesEx_ex1()
{
    string filename =  "c:\\config.sys";

    WIN32_FILE_ATTRIBUTE_DATA    fileInfo;

    if(GetFileAttributesEx(filename, 0, &fileInfo))
    {
        int    nSize = fileInfo.nFileSizeLow;
        out_int("File size=", nSize);
    }
    else
        out_str("file not found");
    return 1;
}

Remark

See Also

GetFileAttributes

Header to Include

origin.h

Reference