Compress the contents of the specified file.
- A string value that is the name of the file that will be compressed. The file must
exist, and it must be a regular file that can be opened for reading
by the current process. An error will be returned if a character
device, such as the console, is specified as the file name.
- A string value that is the name of the file that is to contain the compressed file
data. If the file exists, it must be a regular file that can be
opened for writing by the current process and will be overwritten.
If the file does not exist, it will be created. An error will be
returned if a character device, such as the console, is specified
as the file name.
- A numeric value which determines the algorithm that will be
used to compress the data. One of the following values may be
specified. If this argument is not specified, the Deflate algorithm
||A compression algorithm that combines LZ77 algorithm for
creating common substrings and Huffman coding to process the
different frequencies of byte sequences in the data stream.
Deflate is widely used by compression software.
||A compression algorithm that rearranges blocks of data in
sorted order and then uses Huffman coding to process
different frequencies of data within the block.
Burrows-Wheeler compression provides a better compression
ratio than the Deflate algorithm, however it requires more
resources to perform the compression.
- A numeric value which specifies the compression level to use. A
value of zero specifies that the default compression level
appropriate for the selected algorithm should be used, balancing
resource usage and the compression ratio of the data. A value of 1
specifies that the compression should be performed using minimal
memory resources, at the expense of the compression ratio. The
maximum value of 9 specifies that the algorithm should use more
memory to achieve the maximum compression ratio. It is recommended
that most applications use the default value of zero.
This method returns a value of zero if the file was successfully
compressed. A non-zero return value specifies an error code which
indicates the reason for the failure.
The CompressFile method compresses the contents of the
specified file. The compression ratio achieved depends on the type of
file being compressed.
It is permitted to specify an empty string as the output file name.
In this case, the control will create a temporary file in the directory
specified by the TEMP environment variable. After the file has been
compressed, the OutputFile property will be set the name of the
temporary file that has been created. It is the responsibility of the
application to delete this temporary file after it is no longer needed.
Note that the compressed file is not stored in an archive format
that is recognized by third-party applications such as PKZip or