This method returns the number of bytes of compressed data that was copied
into the output buffer. If the input buffer is a zero-length string or
an empty array, the method will return zero. If an error occurs, the
method will return -1. Check the value of the LastError
property to determine the specific error that has occurred.
The CompressData method compresses the contents of a
string or byte array in memory, rather than using a temporary file.
The type of variable passed to the method as the output buffer
determines whether the data is base644 encoded or not. If the output
buffer is a string type then the compressed data will be automatically
encoded to ensure that it can be safely represented as a string. If
the output buffer is a byte array, the compressed data will be copied
into the array as-is without any encoding. If the caller specifies a
fixed-size byte array as the output buffer, the array must be large
enough to contain all of the compressed data, otherwise the method
will fail.
The return value from this method should always be checked to
ensure that the data was successfully compressed. An application
should never assume that the output buffer contains valid compressed
data unless the return value is greater than zero. The compressed
data is not returned in a format that is recognized by third-party
applications such as PKZip or WinZip. To expand the compressed data,
pass the contents of the output buffer to the ExpandData method.