Universal Extractor for .NET
Introduction to Universal Extractor for .NET
The Universal Extractor for .NET is a plugin that allows developers to extract archives and compressed files in various formats, including ZIP, RAR, 7Z, TAR, GZIP, and more. This guide provides an overview of the available features and explains how to perform common tasks using code examples in .NET.
Supported Archive Formats
The Universal Extractor for .NET supports a wide range of archive formats, including:
- ZIP (.zip)
- RAR (.rar)
- 7Z (.7z)
- TAR (.tar)
- GZIP (.gz)
- BZIP2 (.bz2)
Extracting Archives
To extract an archive using the Universal Extractor for .NET, you can use the following code example:
using System.IO;
using Aspose.Zip;
// Create a new instance of the Archive class
using (var archive = new Archive("example.zip"))
{
// Extract the archive to a directory
archive.ExtractToDirectory("extracted");
}
This code extracts the contents of the example.zip
archive to a directory named extracted
.
Extracting Archives with Password Protection
If an archive is password-protected, you can extract it using the following code example:
using System.IO;
using Aspose.Zip;
// Create a new instance of the Archive class
using (var archive = new Archive("example.zip"), new ArchiveLoadOptions() { DecryptionPassword = "YOUR-PASSWORD" })
{
// Extract the archive to a directory
archive.ExtractToDirectory("extracted");
}
This code extracts the contents of the example.zip
archive, which is protected with a password, to a directory named extracted
.
Listing Archive Contents
To list the contents of an archive without extracting it, you can use the following code example:
using System.IO;
using Aspose.Zip;
// Create a new instance of the Archive class
using (var archive = new Archive("example.zip"))
{
// Get the entries in the archive
var entries = archive.Entries;
// Iterate over the entries and print their names
foreach (var entry in entries)
{
Console.WriteLine(entry.Name);
}
}
This code lists the contents of the example.zip
archive without extracting it.