Overview

Sometimes you need to add files to existing archives. Aspose.ZIP allows adding entries to ZIP, TAR, and CPIO archives without repacking the entire archive, saving time and resources, especially for frequently updated archives.

ZIP

Managing archives often involves adding new files. Aspose.ZIP provides a convenient way to update existing ZIP archive without the need to completely rebuild them. This can save time and resources, especially for frequently updated archives.

    with zp.Archive("existing.zip") as archive:
        archive.create_entry("one_more.bin", "data.bin")
        archive.save("added.zip")

This code snippet opens an existing ZIP archive named existing.zip and adds a new entry called one_more.bin by copying the contents from data.bin. After adding the new entry, the updated archive is saved as added.zip. This process effectively modifies the original ZIP archive by including an additional file while preserving the existing contents.

TAR

The following code demonstrates how to effortlessly add a file to an existing TAR archive using Aspose.ZIP API. This approach is efficient and avoids recreating the entire archive, making it ideal for scenarios where you need to keep your archives up-to-date.

with zp.tar.TarArchive("existing.tar") as archive:
    archive.create_entry("one_more.bin", "data.bin")
    archive.save("added.zip")

CPIO

This code snippet showcases how to incorporate a new file named "data.bin" into an existing CPIO archive named "existing.zip".

    with zp.cpio.CpioArchive("existing.cpio") as archive:
        archive.create_entry("one_more.bin", "data.bin")
        archive.save("added.zip")

These code examples simplify managing archives in ZIP, Tar, or CPIO formats. They allow updating existing archives by adding new files without creating entirely new ones. This optimizes storage, simplifies data organization, and even enhances security by enabling encrypted archives to be updated with new protected files.

Other Supported Aspose.ZIP for Python.Net API Features

With the Aspose.ZIP library in Python.Net, you can seamlessly handle various tasks related to ZIP file documents. Whether you need to convert formats, merge files, edit contents, or extract data, Aspose.ZIP provides comprehensive functionality to streamline your workflow and enhance productivity.

  

Support and Learning Resources

  
  

Aspose.Zip offers individual archive processing APIs for other popular development environments, listed below: