Unrar or Extract Files Programmatically using C#

Unrar Extract Files Csharp

You can store multiple files in compressed form as RAR archive. In this article, you will learn how to Unrar or extract files from a compressed RAR archive. Please find further details in the following sections:

Unrar RAR4 RAR5 Files with RAR Extractor or Opener – C# API Installation

Aspose.ZIP for .NET API supports archiving and extracting files from compressed formats like RAR (RAR4, RAR5), ZIP, 7Z, etc. You can install the API by downloading it from the Downloads section, or you can configure it with the following command using Package Manager Console in Microsoft Visual Studio:

PM> Install-Package Aspose.Zip

Unrar or Extract a Specific File from RAR Programmatically using C#

You can unrar or extract a specific file from a RAR archive with the following steps:

  1. Load input RAR file with RarArchive class object.
  2. Create a file with Create() method.
  3. Open a specific entry from the RAR archive.
  4. Write extracted data to a file.

The code below shows how to unrar or extract a specific file from RAR archive programmatically with C#:

Extract or Unrar All Files from RAR Archive Programmatically with C#

You can unrar or extract all the files from a RAR archive with the following steps:

  1. Load input RAR file.
  2. Extract all the files to a directory.

The following code shows how to unrar all files from RAR archive programmatically using C#:

Unrar a Particular File from Password Protected RAR Archive using C#

You can unrar a particular file from a password protected RAR archive with the steps below:

  1. Load the RAR file Encrypted with Password.
  2. Specify the file name for the output file.
  3. Unrar the password-protected file with Extract() method.

The following code explains how to unrar a particular file from a password protected or encrypted archive using C#:

Unrar all Files from Password Protected RAR Archive Programmatically with C#

You can extract all the files from a password encrypted RAR archive with below steps:

  1. Load an encrypted RAR file.
  2. Unrar or extract password-protected files from the archive.

The following code snippet shows how to unrar all files from a password encrypted RAR file programmatically using C#:

Get Free License

You can evaluate the API without any limitations by applying for a Free Temporary License.

Conclusion

In this article, you have learned all the use cases about how to unrar or extract files from the RAR archive. It also discusses the scenario when the RAR file is encrypted with password protection where you can extract a specific file or all the files into a directory. Furthermore, you may visit API Documentation to check out several other features. Please feel free to contact us at the Free Support Forum for any queries.

See Also

Add Files or Folders to ZIP Archives Programmatically in C#