Sample code for 30+ languages & platforms
Visual FoxPro

Deflate File

Demonstrates how to use the Deflate compression algorithm to compress a file. (The deflate compression algorithm is the most commonly used in the Zip archive file format.)

This code is capable of compressing any size file because the file data is compressed from input to output in a streaming mode. The output file contains only the deflated data (it is not a .zip, and there is no file structure or format).

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loCompress

lnSuccess = 0

* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.

loCompress = CreateObject('Chilkat.Compression')

loCompress.Algorithm = "deflate"

* Deflate this XML file:
lnSuccess = loCompress.CompressFile("hamlet.xml","hamletDeflate.dat")
IF (lnSuccess <> 1) THEN
    ? loCompress.LastErrorText
    RELEASE loCompress
    CANCEL
ENDIF

* Inflate back to the original:
lnSuccess = loCompress.DecompressFile("hamletDeflate.dat","hamletInflated.xml")
IF (lnSuccess <> 1) THEN
    ? loCompress.LastErrorText
    RELEASE loCompress
    CANCEL
ENDIF

? "Success!"

RELEASE loCompress