大网数据广告活动
磁盘与文件系统

File Compression and Decompression

· 52CE 我爱测

The NTFS file system uses Lempel-Ziv compression, which is a lossless compression algorithm.

The NTFS file system volumes support file compression on an individual file basis. The file compression algorithm used by the NTFS file system is Lempel-Ziv compression. This is a lossless compression algorithm, which means that no data is lost when compressing and decompressing the file, as opposed to lossy compression algorithms such as JPEG, where some data is lost each time data compression and decompression occur.

Data compression reduces the size of a file by minimizing redundant data. In a text file, redundant data can be frequently occurring characters, such as the space character, or common vowels, such as the letters e and a; it can also be frequently occurring character strings. Data compression creates a compressed version of a file by minimizing this redundant data.

Each type of data-compression algorithm minimizes redundant data in a unique manner. For example, the Huffman encoding algorithm assigns a code to characters in a file based on how frequently those characters occur. Another compression algorithm, called run-length encoding, generates a two-part value for repeated characters: the first part specifies the number of times the character is repeated, and the second part identifies the character. Another compression algorithm, known as the Lempel-Ziv algorithm, converts variable-length strings into fixed-length codes that consume less space than the original strings.

The NTFS File System File Compression

On the NTFS file system, compression is performed transparently. This means it can be used without requiring changes to existing applications. The compressed bytes of the file are not accessible to applications; they see only the uncompressed data. Therefore, applications that open a compressed file can operate on it as if it were not compressed. However, these files cannot be copied to another file system.

If you compress a file that is larger than 30 gigabytes, the compression may not succeed.

The following topics identify the NTFS file system file compression:

File Compression and Decompression Libraries

The file compression and decompression libraries take an existing file or files and produce a file or files that are compressed versions of the originals. The compression is also lossless, but the compression is not transparent to applications. An application can only operate on such files with the assistance of a file compression library. In addition, the only operations you can perform on such files are creating a compressed file from an original and recovering the original data from the decompressed version. Editing is typically not supported, and seeking is limited if supported at all.

Typically, an application calls functions in Lz32.dll to decompress data that was compressed using Compress.exe. The functions can also process files without attempting to decompress them.

You can use the functions in Lz32.dll to decompress single or multiple files. You can also use them to decompress compressed files a portion at a time.

The following topics identify the file decompression that is provided by the functions in Lz32.dll:

Cabinets

Cabinets are created by a compression library that supports features such as disk spanning and multi-file compression. For additional information, see the Cabinet Software Development Kit: https://msdn.microsoft.com/library/dncabsdk/html/cabdl.asp.

In this section

Topic Description
Compression Attribute On an NTFS file system volume, each file and directory has a compression attribute.
Compression State Each file and directory on a volume that supports compression for individual files and directories has a compression state.
Obtaining the Size of a Compressed File To obtain the compressed size of a file use the GetCompressedFileSize function.
Decompressing a Single File An application can decompress a single compressed file by using the LZOpenFile, LZCopy, and LZClose functions.
Decompressing Multiple Files An application can decompress multiple files by using the LZOpenFile, LZCopy, and LZClose functions.
Reading from Compressed Files An application can decompress a compressed file a portion at a time by using the LZSeek and LZRead functions.

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。