![]() |
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
(PowerBuilder) 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.
integer li_rc integer li_Success oleobject loo_Zip string ls_Charset oleobject loo_Zip2 oleobject loo_Entry li_Success = 0 li_Success = 0 // ------------------------------------------------------------ // First create a ZIP archive containing three text files. 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.NewZip("original.zip") if li_Success = 0 then Write-Debug loo_Zip.LastErrorText destroy loo_Zip return end if ls_Charset = "utf-8" li_Success = loo_Zip.AddString("a.txt","Contents of file A",ls_Charset) if li_Success = 0 then Write-Debug loo_Zip.LastErrorText destroy loo_Zip return end if li_Success = loo_Zip.AddString("b.txt","Contents of file B",ls_Charset) if li_Success = 0 then Write-Debug loo_Zip.LastErrorText destroy loo_Zip return end if li_Success = loo_Zip.AddString("c.txt","Contents of file C",ls_Charset) if li_Success = 0 then Write-Debug loo_Zip.LastErrorText destroy loo_Zip return end if // Write the ZIP archive to disk. // // The ZIP now contains: // // a.txt // b.txt // c.txt // li_Success = loo_Zip.WriteZipAndClose() if li_Success = 0 then Write-Debug loo_Zip.LastErrorText destroy loo_Zip return end if // ------------------------------------------------------------ // Open the existing ZIP archive for modification. loo_Zip2 = create oleobject li_rc = loo_Zip2.ConnectToNewObject("Chilkat.Zip") li_Success = loo_Zip2.OpenZip("original.zip") if li_Success = 0 then Write-Debug loo_Zip2.LastErrorText destroy loo_Zip destroy loo_Zip2 return end if // Find the entry named "b.txt". loo_Entry = create oleobject li_rc = loo_Entry.ConnectToNewObject("Chilkat.ZipEntry") li_Success = loo_Zip2.EntryOf("b.txt",loo_Entry) if li_Success = 0 then Write-Debug loo_Zip2.LastErrorText destroy loo_Zip destroy loo_Zip2 destroy loo_Entry return end if // 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. li_Success = loo_Zip2.DeleteEntry(loo_Entry) if li_Success = 0 then Write-Debug loo_Zip2.LastErrorText destroy loo_Zip destroy loo_Zip2 destroy loo_Entry return end if // Write the modified ZIP archive to a new file. loo_Zip2.FileName = "modified.zip" li_Success = loo_Zip2.WriteZipAndClose() if li_Success = 0 then Write-Debug loo_Zip2.LastErrorText destroy loo_Zip destroy loo_Zip2 destroy loo_Entry return end if // The modified ZIP now contains: // // a.txt // c.txt // Write-Debug "ZIP archive updated successfully." destroy loo_Zip destroy loo_Zip2 destroy loo_Entry |
||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.