Compression Attribute

On an NTFS file system volume, each file and directory has a compression attribute. Other file systems may also implement a compression attribute for individual files and directories.

You can determine whether a file system supports a compression attribute for files and directories by calling the GetVolumeInformation function and examining the FILE_FILE_COMPRESSION bit flag.

Use the GetFileAttributes or GetFileAttributesEx function to determine the compression attribute of a file or directory.

If a file's compression attribute is set (FILE_ATTRIBUTE_COMPRESSED), all data in the file is compressed. If the attribute is clear, none of the data in the file is compressed. There is no partially compressed state from a user-mode programming perspective; the compression attribute is a simple Boolean indicator of compression state.

A directory's compression attribute provides a default compression attribute for newly created files and subdirectories. When you call CreateFile or CreateDirectory to create a new file or directory, the new file or directory inherits the compression attribute of its parent directory.

To modify the FILE_ATTRIBUTE_COMPRESSED attribute for a file or directory, you must use the DeviceIoControl function with the FSCTL_SET_COMPRESSION control code.

File Attribute Constants