Overview

Aspose.ZIP for Python via .NET API simplifies file and folder archiving in your Python applications. It offers a variety of techniques for storing and compressing data, compatible with popular applications. The API grants you full control over archive creation and password protection using user-defined passwords. Additionally, Aspose.ZIP empowers you to secure ZIP archives with both traditional and AES encryption methods. This robust and user-friendly API streamlines data archiving tasks within your Python projects.

Integrating Compression API in a Python.Net Application

Maximize the efficiency of your Python application with compression. In this section, we will reveal the secrets of integrating the Compression API to improve the performance and efficiency of your Python project. From optimizing file size to improving data storage, learn how to seamlessly implement compression, giving your application advanced capabilities. Dive into the details of the Compression API and elevate your ython.Net development experience.

    import aspose.zip as zp

    with zp.Archive() as archive:
        archive.create_entry("entry_name.dat", "input_file.dat")
        archive.save('my_archive.zip')

Creating an Archive from One or More Files Using Python.Net

Python empowers you to create compressed archives containing multiple files. This process involves creating file streams for both the output archive and the files to be compressed, followed by adding them to an Archive object and saving the final archive.

How to Add files to archives without compression via Python.Net

Following the theme of efficient archive management, consider when compression might be unnecessary. This is especially true for file formats that are already compressed, such as JPEG images, MP4 videos, or even pre-compressed archives like ZIP files. To avoid redundant compression, you can save the archive in “store” mode, which simply groups the files together without applying any further compression. While “store” mode is useful in specific situations, our library provides further options for creating archives using various formats, which we’ll explore next.

    with io.FileIO("archive.zip", 'x') as zipFile: 
        store_settings = zp.saving.ArchiveEntrySettings(zp.saving.StoreCompressionSettings()) 
        with zp.Archive(store_settings) as archive:
            archive.create_entry("alice29.txt", "alice29.txt")
            archive.create_entry("asyoulik.txt", "asyoulik.txt")
            archive.save(zipFile)

Encrypting and Decrypting: Safeguarding Your Archive's Integrity

Security is paramount, especially when dealing with sensitive data within archives. This section focuses on the crucial aspects of encrypting and decrypting archives, providing a robust shield for your information. Whether you need to secure the entire archive or specific entries, learn the techniques and best practices to ensure the integrity and confidentiality of your data.

How To Add entries to existing archive

Adding entries to existing archives is a powerful technique for selective file updates, ensuring only relevant data remains. This saves valuable disk space, especially when storage is limited or you rely on cloud storage. Additionally, by avoiding redundant data and keeping only current versions of files, you streamline searches and maintain a focused archive. This makes adding entries a crucial strategy for efficient archive management.

How To Delete entries from existing archive

Deleting entries from existing archives is a powerful technique for selective file removal and archive management, ensuring only relevant data remains. This frees up valuable disk space, especially when storage is limited or you rely on cloud storage. Additionally, by deleting redundant data and keeping only current versions of files, you streamline searches and maintain a focused archive. This makes deleting entries a crucial strategy for efficient archive management.

How to Compress folder respecting its structure

Python.Net allows compression of entire folders, maintaining the original file structure within the archive. This ensures that your compressed data remains organized and easy to navigate after extraction.

How to Decompress to directory respecting archive structure

Just like efficient compression, fast and organized extraction is essential. This section delves into the secrets of decompressing archives while maintaining their original folder structure. Learn powerful techniques to extract files quickly, ensuring your decompressed content stays meticulously organized and readily accessible.

Parallel compression

Unleash faster compression with our library’s support for multi-stream compression in certain formats. This can significantly boost your data processing speed. To understand the available options for Parallel Compression consult the documentation. Experiment with these settings to find the optimal configuration for your specific hardware and use case.

Parallel compression to 7Z LZMA2

    compression_settings = zp.saving.SevenZipLZMA2CompressionSettings()
    compression_settings.compression_threads = 4
    entry_settings = zp.saving.SevenZipEntrySettings(compression_settings)
    with zp.sevenzip.SevenZipArchive(entry_settings) as archive:
        archive.create_entry("data.bin", "data.bin")
        archive.save("result.7z")
  

Support and Learning Resources

  
  

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