Reliable File Compression and Archiving API for .NET

Create archives of ZIP, 7ZIP, RAR, GZIP, TAR, LZ, BZ2, CAB, and more types with the Aspose file compression and archiving API for .NET. Seamlessly compress, decompress, and encrypt archives with AES and ZIPCrypto encryption

Download Free TrialView All APIs

Master Compression and Archiving on The .NET Platform

Aspose.ZIP for .NET is a feature-rich, standalone file compression, decompression, archiving, and encryption API. Developers can use the .NET API to compress files and folders to create archives of ZIP, RAR, 7ZIP, TAR, GZIP, CAB, BZ2, CPIO, LZ, and more types. It allows developers to manipulate the archives and supports adding or removing files to and from existing archives and inserting files without compression into the archives. The .NET compression library also includes powerful security features and enables securing the archives with the help of custom passwords, ZIPCrypto, and EAS encryption (AES128, AES192, and AES256) standards.

The file compression API for .NET supports extracting archive entries and creating self-extracting archives as part of its comprehensive feature set. Users can build extensive .NET solutions targeting desktop and web interfaces that can run on multiple OS or platforms with Aspose.ZIP for .NET. It does not require installing additional software to function, and it helps developers independently master document compression and archiving within their .NET apps.

Getting Started

The information given below will help you correctly set up Aspose.ZIP for .NET at your end. Please check a list of prerequisites on the System Requirements page before you install the file compression API to ensure your system meets the recommended settings.

Aspose.ZIP for .NET Installation

Please download the DLLs or the MSI installer of the archive file manipulation library from the downloads section to install it. Alternatively, you can obtain the NuGet package and set up the library from the Visual Studio Package Manager Console using the below-given command:

PM > Install-Package Aspose.Zip

Seamlessly Create ZIP Archives and Convert Them in .NET

Aspose.ZIP for .NET helps developers programmatically create ZIP archives by compressing single or multiple files or folders. It enables developers to build reliable archiving solutions offering extensive features, including compression, extraction, and encryption of the archives. In addition to the advanced archive management capabilities, the .NET API for file compression also offers the ability to seamlessly convert archives from one format to another.

Create ZIP Archives with Multiple Files in C#

ZIP archives are one of the most common archive types, used globally to compress files and folders. ZIP archives are popular among users of different OS and platforms, placing them in a select group of universally accepted compression and archiving formats. Developers can efficiently create ZIP archives by adding more than one file within their C# .NET apps. In this coding example, we will review how to compress files in C# .NET using the .NET ZIP API by archiving multiple files. Let's check out the following steps and information for more.

// Create FileStream for output ZIP archive
using (FileStream zipFile = File.Open("compressed_files.zip", FileMode.Create))
{
            	// File to be added to archive
            	using (FileStream source1 = File.Open("alice29.txt", FileMode.Open, FileAccess.Read))
            	{
                            	// File to be added to archive
                            	using (FileStream source2 = File.Open("asyoulike.txt", FileMode.Open, FileAccess.Read))
                            	{
                                            	using (var archive = new Archive())
                                            	{
                                                            	// Add files to the archive
                                                            	archive.CreateEntry("alice29.txt", source1);
                                                            	archive.CreateEntry("asyoulik3.txt", source2);
                                                            	// ZIP the files
                                                            	archive.Save(zipFile, new ArchiveSaveOptions() { Encoding = Encoding.ASCII, ArchiveComment = "two files are compressed in this archive" });
                                            	}
                            	}
            	}
}


How to Effortlessly Convert Archives in .NET

Converting archives of different types from one format to another is supported by the .NET archive creating and extraction library. The following code example explains how developers can convert a RAR file to ZIP format within their .NET apps. Let’s review the steps involved in the conversion process.

// Create an instance of Archive class for ZIP archive
using (Archive zip = new Archive())
{
	// Load the RAR archive
	using (RarArchive rar = new RarArchive(@"D:\archvie.rar"))
	{
    	// Loop through entries of RAR file
    	for (int i = 0; i < rar.Entries.Count; i++)
    	{
         	// Copy each entry from RAR to ZIP
         	if (!rar.Entries[i].IsDirectory)
         	{
             	var ms = new MemoryStream();
             	rar.Entries[i].Extract(ms);
             	ms.Seek(0, SeekOrigin.Begin);
                 zip.CreateEntry(rar.Entries[i].Name, ms);
         	}
         	else
                 zip.CreateEntry(rar.Entries[i].Name + "/", Stream.Null);
     	}
 	}
	// Save the resultant ZIP archive
	zip.Save("output.zip");
}


You can view more working code examples at the GitHub examples page of the Aspose.ZIP for .NET API. We provide Free Online Archiving and Encryption Apps to help you open, merge, convert, zip, unzip, encrypt, and decrypt files on the fly using your mobile devices, so please feel free to check out the free apps.

Advanced Archive Extraction Functionality in .NET

Together with the unmatched compression and archiving capabilities of Aspose.ZIP for .NET, it boasts the ability to decompress and extract files from archives of different types, including ZIP, RAR, TAR, GZIP, 7ZIP, and more. Developers can use the high-performance archive file manipulation library for programmatically extracting the files compressed and added to the archives across multiple operating systems. The functionality of extracting archives also extends to password-protected files, allowing users to extract files from secure archive files in .NET.

FAQ

1. How can I convert archive files on the .NET platform?

Converting archive files in .NET is quick and easy using the file compression API for .NET. It supports working with archives in C# .NET efficiently and converting them to and from different formats. You can convert RAR to ZIP, ZIP to TAR, ZIP to 7ZIP, and more.

2. How long it takes to compress and archive files?

The .NET archiving library works fast and completes your archive file creation, manipulation, protection, and extraction requests in no time.

3. Is it safe to compress and archive files using the .NET API?

You can be sure of the security of your data files while processing them using the .NET archive API. We ensure the privacy of your data and take all required measures to provide you with a secure user experience.

4. Can I process archives on Mac OS, Windows, or Linux?

Yes, the library works across different OS, frameworks, and operating environments. You can use it on the platform of your choice, and it does not require any additional software installation to function.

Looking for help?

Checkout our support channels for help with your questions related to Aspose product API features and working.

Ready to get started?

Download Free Trial View All APIs