Overview
For each format, which supports several entries, the corresponding class have extract_to_directory method. It should be used to extract whole archive content, including sub-folders into specified location.ZIP Unzip Archive Files
Below is an example of using the aspose.zip library to work with ZIP archives. Using the given code, you can extract the contents of the archive to the given directory using Python.
with zp.Archive("archive.zip") as archive:
archive.extract_to_directory("C:\\extracted")
Unpack RAR Files
with zp.rar.RarArchive("archive.rar") as archive:
archive.extract_to_directory("C:\\extracted")
Decompress CAB Files
with zp.cab.CabArchive("archive.cab") as archive:
archive.extract_to_directory("C:\\extracted")
These code examples showcase how to unpack archives of various formats using the Aspose.Zip library in Python. They employ the appropriate classes for ZIP, RAR, and CAB archives to extract their contents into a designated "C:\extracted" directory. This approach offers a universal solution for handling various archive formats, streamlining the unpacking process.
How to Extract TAR File
This section provides examples of using the Aspose.Zip library. The following code demonstrates how to extract archive contents from a stream to a specified directory. These examples will equip you to effectively manage archives within your Python projects.
with io.FileIO("archive.tar") as tar_file:
with zp.tar.TarArchive(tar_file) as archive:
archive.extract_to_directory("~/extracted")
Extract a XAR File
with io.FileIO("archive.xar") as tar_file:
with zp.xar.XarArchive(xar_file) as archive:
archive.extract_to_directory("~/extracted")
These code examples demonstrate unpacking archives in TAR and XAR formats to a designated directory. The first example opens the "archive.tar" file, creates a TarArchive object, and extracts its contents to the "\extracted" directory. Similarly, the second example opens the "archive.xar" file, creates a XarArchive object, and extracts its contents to the same "\extracted" directory.
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
- Learning Resources
- Documentation
- Source Code
- API References
- Product Support
- Free Support
- Paid Support
- Blog
- Release Notes
- Why Aspose.Zip for Python.Net?
- Customers List
- Success Stories