Unzipping with Structure Preservation in Aspose.ZIP

All of multi-entries archive classes in Aspose.ZIP have ExtractToDirectory method. This method extracts entire archive content to the folder provided respecting nested subfolders. Here are some samples of its usage, all essentially the same.

How to Decompress ZIP-Archive

Imagine you have a ZIP archive with neatly organized files and subfolders. Aspose.ZIP’s ExtractToDirectory method simplifies unpacking this archive while maintaining the original structure. With a clean and intuitive interface, users can easily decompress files to designated directories, preserving organizational integrity.
Whether dealing with multiple entries or nested subfolders, this versatile feature ensures a hassle-free extraction process. For ZIP archives, this means your extracted files will be placed in the designated folder, with subfolders mirroring the organization inside the archive. This ensures a clean and well-organized extraction process, saving you time and effort in manually recreating the folder hierarchy.

    using (FileStream zipFile = File.Open("archive.zip" , FileMode.Open))
    {
        using (Archive archive = new Archive(zipFile))
        {
            archive.ExtractToDirectory("C:\\extracted");
        }
    }

How to Decompress RAR-Archive Respecting its Structure

The RarArchive object, likely created using a library like RarLib, handles the decompression of an archive named "archive.rar". A single call to the ExtractToDirectory method efficiently extracts the archive’s contents to the specified directory, "C:\extracted". This streamlined process ensures the safe extraction of all files and subfolders, promoting seamless integration into your application workflow. Discover the ease and reliability of archive extraction with the right tools.

    using (RarArchive archive = new RarArchive("archive.rar")) 
    { 
        archive.ExtractToDirectory("C:\\extracted");
    }

Decompress CAB Respecting its Structure

Effortlessly unpack CAB archives using the CabArchive class. A single line of code with the ExtractToDirectory method efficiently extracts the contents of "archive.cab" to your designated directory, "C:\extracted". This streamlined process ensures all files and subfolders maintain their original structure, guaranteeing a smooth extraction experience. Integrate this functionality for seamless CAB archive handling within your application.

    using (CabArchive cabArchive = new CabArchive("archive.cab"))
    {
        cabArchive.ExtractToDirectory("C:\\extracted");
    }

Extract TAR with Structure Intact

Effortlessly extract TAR archives while maintaining their folder structure using the ExtractToDirectory method. This functionality, often available in libraries separate from Aspose.ZIP, simplifies the extraction process and ensures all files remain organized within your chosen output directory.
Sample:

    using (FileStream tarFile = File.Open("archive.tar", FileMode.Open))
    {
        using (TarArchive archive = new TarArchive(tarFile))
        {
            archive.ExtractToDirectory("C:\\extracted");
        }
    }

Unpack XAR with Structure Retained

Extracting XAR archives becomes a breeze with the ExtractToDirectory method (available in libraries designed for XAR handling). This method ensures a streamlined process, maintaining the original folder structure of the archive within your chosen output directory. No need to manually recreate folders – all files are placed in their proper locations, saving you time and effort.
Sample:

    using (FileStream xarFile = File.Open("archive.xar", FileMode.Open))
    {
        using (XarArchive archive = new XarArchive(xarFile))
        {
            archive.ExtractToDirectory("C:\\extracted");
        }
    }
  

Support and Learning Resources

  
  

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