Sample code for 30+ languages & platforms
PowerBuilder

Uncompress a Gzip File to a Specific Output File

See more Gzip Examples

This example demonstrates how to use the UncompressFile method to decompress a Gzip (.gz) file and write the uncompressed data to a specified output file.

The method reads the compressed input file and writes the decompressed contents to the output path provided. The output filename is explicitly specified by your application and does not depend on the filename embedded within the Gzip file.

This provides full control over where and how the decompressed file is created.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Gzip
string ls_GzPath
string ls_OutPath

li_Success = 0

// This example demonstrates how to uncompress a Gzip (.gz) file
// and write the uncompressed output to a specified file.

loo_Gzip = create oleobject
li_rc = loo_Gzip.ConnectToNewObject("Chilkat.Gzip")
if li_rc < 0 then
    destroy loo_Gzip
    MessageBox("Error","Connecting to COM object failed")
    return
end if

// The input Gzip file and output file:
ls_GzPath = "example.txt.gz"
ls_OutPath = "output.txt"

// Uncompress the file:
li_Success = loo_Gzip.UncompressFile(ls_GzPath,ls_OutPath)
if li_Success = 0 then
    Write-Debug loo_Gzip.LastErrorText
    destroy loo_Gzip
    return
end if

Write-Debug "Gzip file successfully uncompressed."
Write-Debug "Output file: " + ls_OutPath


destroy loo_Gzip