Extract Open 7z

Introduction

7z files are widely recognized for their impressive compression ratios, making them a popular choice for data storage and transfer. In this guide, you will learn how to open or extract 7z (7zip) files programmatically in your C# applications.

Table of Contents

7z File (7zip) Extractor – C# API Installation

To work with 7z files in your applications, you can utilize the Aspose.ZIP for .NET API. This powerful library supports a variety of compressed formats, including ZIP, RAR, and 7z.

To get started, install it via NuGet with the following command:

PM> Install-Package Aspose.Zip

Open or Extract 7z File (7zip) Programmatically using C#

To open or extract 7z files programmatically, follow these steps:

  1. Load the input 7z (7zip) archive using the SevenZipArchive class.
  2. Use the ExtractToDirectory method to extract all files from the 7zip archive to a specified directory.

Here’s a sample code snippet:

using Aspose.Zip.SevenZip;
using System.IO;

class Program
{
    static void Main()
    {
        using (SevenZipArchive archive = new SevenZipArchive("input.7z"))
        {
            archive.ExtractToDirectory("output_folder");
        }
    }
}

Extract or Unzip Password-Protected 7zip File using C#

To extract a password-protected 7zip file, follow these steps:

  1. Load the encrypted 7z archive.
  2. Use the ExtractToDirectory method, providing the password.

Here’s the implementation:

using Aspose.Zip.SevenZip;
using System.IO;

class Program
{
    static void Main()
    {
        using (SevenZipArchive archive = new SevenZipArchive("protected.7z"))
        {
            archive.ExtractToDirectory("output_folder", "your_password");
        }
    }
}

Get Free API License

You can evaluate the Aspose.ZIP API without any limitations by requesting a Free Temporary License.

Conclusion

In this article, you learned how to open or extract 7z files programmatically using C#. You also explored methods for handling password-protected archives in your .NET applications. For further assistance, visit the Free Support Forum, or check out our API Documentation.

With the Aspose Plugin, you can handle 7z file manipulation effortlessly, making it an essential tool for implementing programmatic 7z extraction in .NET applications.