Select language
  1. Products
  2. Aspose.ZIP
  3. RAR Extractor
clearbit icon

RAR Extractor for .NET

Extract encrypted or not RAR archive with Aspose.ZIP Product Family

Features:

1. Open RAR archive by path or from stream.

2. Supports RAR4 and RAR5 formats.

3. Can decrypt password-protected file.

Extract RAR archive

RAR archives are widely used for universal data compression and encryption.

Sample code for extracting whole RAR archive to directory by path

1
2
3
4
using(RarArchive a = new RarArchive("archive.rar")
{
    a.ExtractToDirectory("C:\\folder");
}

Sample code for extracting the first entry of RAR archive to stream

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
using (RarArchive archive = new RarArchive("archive.rar"))
{
     using (var source = archive.Entries[0].Open())
     {
          byte[] buffer = new byte[4096];
          int bytesRead;
          while ((bytesRead = source.Read(buffer, 0, buffer.Length)) > 0)
              destination.Write(buffer, 0, bytesRead);
     }
}

How to extract RAR via .NET


  1. Reference Aspose.ZIP in your project
  2. Set license
  3. Create instance of RarArchive class
  4. Pass path to archive as the parameters
  5. Call ExtractToDirectory() to extract all entries

System Requirements

Just make sure that you have the following prerequisites.

  • Microsoft Windows or a compatible OS with .NET Framework or .NET Core
  • Development environment like Microsoft Visual Studio.
  • Aspose.ZIP for .NET DLL referenced in your project.