PowerBuilder
PowerBuilder
Change a Filename before Unzipping
See more Zip Examples
How to open a zip and modify the filename of one or more files within the zip before unzipping.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Zip
oleobject loo_Entry
integer li_NumFilesUnzipped
li_Success = 0
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Zip = create oleobject
li_rc = loo_Zip.ConnectToNewObject("Chilkat.Zip")
if li_rc < 0 then
destroy loo_Zip
MessageBox("Error","Connecting to COM object failed")
return
end if
li_Success = loo_Zip.OpenZip("test.zip")
if li_Success = 0 then
Write-Debug loo_Zip.LastErrorText
destroy loo_Zip
return
end if
loo_Entry = create oleobject
li_rc = loo_Entry.ConnectToNewObject("Chilkat.ZipEntry")
li_Success = loo_Zip.EntryOf("hamlet.xml",loo_Entry)
if li_Success = 0 then
Write-Debug loo_Zip.LastErrorText
destroy loo_Zip
destroy loo_Entry
return
end if
loo_Entry.FileName = "hamlet2.xml"
li_Success = loo_Zip.EntryOf("helloWorld.pl",loo_Entry)
if li_Success = 0 then
Write-Debug loo_Zip.LastErrorText
destroy loo_Zip
destroy loo_Entry
return
end if
loo_Entry.FileName = "hw.pl"
// Now unzip to the "test" subdirectory, under our current
// working directory:
li_NumFilesUnzipped = loo_Zip.Unzip("test")
if li_NumFilesUnzipped < 0 then
Write-Debug loo_Zip.LastErrorText
destroy loo_Zip
destroy loo_Entry
return
end if
// The filenames within the .zip are unchanged, but it unzipped
// test/hw.pl and test/hamlet2.xm
destroy loo_Zip
destroy loo_Entry