![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java JavaScript Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(AutoIt) Remove an Entry from an Existing ZIP Using DeleteEntry
This example demonstrates how to use the The example:
Suppose the original ZIP archive contains:
After deleting
The entry is removed only from the in-memory ZIP object until a
Note: This example requires Chilkat v11.0.0 or greater.
Local $bSuccess = False $bSuccess = False ; ------------------------------------------------------------ ; First create a ZIP archive containing three text files. $oZip = ObjCreate("Chilkat.Zip") $bSuccess = $oZip.NewZip("original.zip") If ($bSuccess = False) Then ConsoleWrite($oZip.LastErrorText & @CRLF) Exit EndIf Local $sCharset = "utf-8" $bSuccess = $oZip.AddString("a.txt","Contents of file A",$sCharset) If ($bSuccess = False) Then ConsoleWrite($oZip.LastErrorText & @CRLF) Exit EndIf $bSuccess = $oZip.AddString("b.txt","Contents of file B",$sCharset) If ($bSuccess = False) Then ConsoleWrite($oZip.LastErrorText & @CRLF) Exit EndIf $bSuccess = $oZip.AddString("c.txt","Contents of file C",$sCharset) If ($bSuccess = False) Then ConsoleWrite($oZip.LastErrorText & @CRLF) Exit EndIf ; Write the ZIP archive to disk. ; ; The ZIP now contains: ; ; a.txt ; b.txt ; c.txt ; $bSuccess = $oZip.WriteZipAndClose() If ($bSuccess = False) Then ConsoleWrite($oZip.LastErrorText & @CRLF) Exit EndIf ; ------------------------------------------------------------ ; Open the existing ZIP archive for modification. $oZip2 = ObjCreate("Chilkat.Zip") $bSuccess = $oZip2.OpenZip("original.zip") If ($bSuccess = False) Then ConsoleWrite($oZip2.LastErrorText & @CRLF) Exit EndIf ; Find the entry named "b.txt". $oEntry = ObjCreate("Chilkat.ZipEntry") $bSuccess = $oZip2.EntryOf("b.txt",$oEntry) If ($bSuccess = False) Then ConsoleWrite($oZip2.LastErrorText & @CRLF) Exit EndIf ; Remove the entry from the in-memory ZIP object. ; ; At this point, the original ZIP file on disk is unchanged. ; The deletion takes effect only after WriteZip or ; WriteZipAndClose is called. $bSuccess = $oZip2.DeleteEntry($oEntry) If ($bSuccess = False) Then ConsoleWrite($oZip2.LastErrorText & @CRLF) Exit EndIf ; Write the modified ZIP archive to a new file. $oZip2.FileName = "modified.zip" $bSuccess = $oZip2.WriteZipAndClose() If ($bSuccess = False) Then ConsoleWrite($oZip2.LastErrorText & @CRLF) Exit EndIf ; The modified ZIP now contains: ; ; a.txt ; c.txt ; ConsoleWrite("ZIP archive updated successfully." & @CRLF) |
||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.