Sample code for 30+ languages & platforms
AutoIt

Append String as a File to a Zip

See more Zip Examples

Demonstrates how to append text data as a file within a zip archive.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

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

$oZip = ObjCreate("Chilkat.Zip")

Local $sZipPath = "c:/temp/test.zip"

; Initialize the zip object, which also sets the FileName property to the path of the zip to be created.
$oZip.NewZip($sZipPath)

; Append a file that will contain the string "Hello World";
Local $sFileContent = "Hello World"
Local $sPathInZip = "txtFiles/helloWorld.txt"
$oZip.AddString($sPathInZip,$sFileContent,"utf-8")

$oZip.FileName = $sZipPath
$bSuccess = $oZip.WriteZipAndClose()
If ($bSuccess = False) Then
    ConsoleWrite($oZip.LastErrorText & @CRLF)
    Exit
EndIf

ConsoleWrite("Success." & @CRLF)