win32file.GetFileAttributesEx

tuple = GetFileAttributesEx(FileName, InfoLevelId , Transaction )

Retrieves attributes for a specified file or directory.

Parameters

FileName : PyUnicode

File or directory for which to retrieve information In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to nearly 32,000 wide characters, call the Unicode version of the function (win32file::GetFileAttributesExW ) and prepend r"\\?\\" to the path.

InfoLevelId=GetFileExInfoStandard : int

An integer that gives the set of attribute information to obtain. See the Win32 SDK documentation for more information.

Transaction=None : PyHANDLE

Handle to a transaction (optional). See win32transaction::CreateTransaction. If this parameter is specified, GetFileAttributesTransacted will be called (requires Vista or later).

Comments

Not all file systems can record creation and last access time and not all file systems record them in the same manner. For example, on Windows NT FAT, create time has a resolution of 10 milliseconds, write time has a resolution of 2 seconds, and access time has a resolution of 1 day (really, the access date). On NTFS, access time has a resolution of 1 hour. Furthermore, FAT records times on disk in local time, while NTFS records times on disk in UTC, so it is not affected by changes in time zone or daylight saving time.

Accepts keyword arguments.

InfoLevelId Information returned
GetFileExInfoStandardTuple representing a WIN32_FILE_ATTRIBUTE_DATA struc

Win32 API References

Search for GetFileAttributesEx at msdn, google or google groups.

Search for GetFileAttributesTransacted at msdn, google or google groups.

Return Value

The result is a tuple of:

Items

[0] int : attributes

File Attributes. A combination of the win32com.FILE_ATTRIBUTE_* flags.

[1] PyTime : creationTime

Specifies when the file or directory was created.

[2] PyTime : lastAccessTime

For a file, specifies when the file was last read from or written to. For a directory, the structure specifies when the directory was created. For both files and directories, the specified date will be correct, but the time of day will always be set to midnight.

[3] PyTime : lastWriteTime

For a file, the structure specifies when the file was last written to. For a directory, the structure specifies when the directory was created.

[4] int/long : fileSize

The size of the file. This member has no meaning for directories.