AutoIt
AutoIt
Replace/Update a FIle in a .zip
See more Zip Examples
Demonstrates how to replace/update a file from a .zip. Note: This requires the entire .zip to be rewritten.Chilkat AutoIt Downloads
Local $bSuccess = False
; This requires the Chilkat Zip API to have been previously unlocked.
; See Unlock Chilkat Zip for sample code.
; First prepare a .zip and write it..
$oZip = ObjCreate("Chilkat.Zip")
$oZip.NewZip("qa_output/abc.zip")
; Add some files..
Local $sCharset = "utf-8"
$oZip.AddString("a.txt","aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",$sCharset)
$oZip.AddString("b.txt","bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",$sCharset)
$oZip.AddString("c.txt","cccccccccccccccccccccccccccccccccccc",$sCharset)
; Write to qa_output/abc.zip
; This .zip contains three files: a.txt, b.txt, and c.txt
$bSuccess = $oZip.WriteZipAndClose()
; -------------------------------------------------------------------
; Open abc.zip, replace the content of the "b.txt" entry with something else, and re-write.
$oZip2 = ObjCreate("Chilkat.Zip")
$oZip2.OpenZip("qa_output/abc.zip")
$oEntry = ObjCreate("Chilkat.ZipEntry")
If ($oZip2.EntryOf("b.txt",$oEntry) = True) Then
$oEntry.ReplaceString("This is the new content. bbbbbbbbbbbbbbbbbbbbbb","utf-8")
EndIf
; Write the modified .zip back to "abc.zip"
$bSuccess = $oZip2.WriteZipAndClose()
ConsoleWrite("success." & @CRLF)