A full-featured .NET wrapper for RARLab's official rar.exe command-line tool. This library empowers .NET developers to seamlessly access and control almost all the functionality provided by rar.exe — such as compressing, extracting, listing, testing, creating recovery volumes and managing RAR archives — from within their applications.
RARLab provides a powerful command-line tool, rar.exe, with deep support for creating and extracting RAR archives. However, using it directly from .NET requires manually spawning processes, constructing CLI arguments, and parsing the textual output — a repetitive and error-prone task.
This project eliminates that friction by wrapping a range of rar.exe functionalities in an intuitive .NET interface.
The wrapper is implemented in VB.NET but is fully compatible with both VB.NET and C# projects. It targets .NET Framework 4.8.1 by default, but can be easily migrated to .NET 5+ without issues, as it relies on no external dependencies other than the user-supplied rar.exe executable.
✅ Archive Creation and Modification Create, fresh or update .rar files from one or multiple files/folders, with support for recursive inclusion, solid archives, volume splitting, and compression tuning.
✅ Extraction Support Extract archives to custom locations, with full support for password-protected archives, overwrite rules, and directory flattening.
✅ Archive Listing Retrieve file lists (size, timestamps, CRC, etc.) from existing archives programmatically.
✅ Password Support Handle encrypted archives with ease, both when creating and extracting, using secure password input.
✅ Advanced RAR Options Expose almost the full range of RAR’s features: recovery records, archive locking, comment injection, timestamps, file exclusions, and more.
✅ Multi-volume Archive Handling Create and extract archives split into multiple volumes — ideal for large datasets or removable media.
✅ Error Handling and Output Parsing
Automatically parse output from rar.exe, detect errors, and raise structured exceptions where appropriate.
✅ Cross-language Usability Though written in VB.NET, the wrapper is compiled into a .NET assembly (a dll library), making it easy to use in C#, F#, and other .NET-supported languages.
✅ No External Dependencies
Only dependency is rar.exe from RARLab — no third-party libraries required.
rar.exefrom RARLab's WinRAR (command-line version only). Please note thatrar.exeis not free, it requires a product license (the same from a licensedWinRARproduct).
Clone this repository or download the latest compilation by clicking here.
Add the project to your solution or reference the compiled DLL file.
Ensure rar.exe is present in your system environment path or specify its full path in the wrapper configuration. A working product license would also be required for using almost all the rar.exe functionalities.
Start compressing or extracting archives with simple method calls!
Imports DevCase.RAR
Imports DevCase.RAR.Commands
Dim archivePath As String = "C:\New Archive.rar"
Dim filesToAdd As String = "C:\Directory to add\"
Dim command As New RarCreationCommand(RarCreationMode.Add, archivePath, filesToAdd) With {
.RarExecPath = ".\rar.exe",
.RarLicenseData = "(Your license key)",
.RecurseSubdirectories = True,
.EncryptionProperties = Nothing,
.SolidCompression = False,
.CompressionMode = RarCompressionMode.Normal,
.DictionarySize = RarDictionarySize.Mb__128,
.OverwriteMode = RarOverwriteMode.Overwrite,
.FilePathMode = RarFilePathMode.ExcludeBaseDirFromFileNames,
.FileTimestamps = RarFileTimestamps.All,
.AddQuickOpenInformation = TriState.True,
.ProcessHardLinksAsLinks = True,
.ProcessSymbolicLinksAsLinks = TriState.True,
.DuplicateFileMode = RarDuplicateFileMode.Enabled,
.FileChecksumMode = RarFileChecksumMode.BLAKE2sp,
.ArchiveComment = New RarArchiveComment("Hello world!"),
.RecoveryRecordPercentage = 0,
.VolumeSplitOptions = Nothing,
.FileTypesToStore = Nothing
}using DevCase.RAR;
using DevCase.RAR.Commands;string archivePath = "C:\\New Archive.rar";
string filesToAdd = "C:\\Directory to add\\";
RarCreationCommand command = new RarCreationCommand(RarCreationMode.Add, archivePath, filesToAdd) {
RarExecPath = ".\\rar.exe",
RarLicenseData = "(Your license key)",
RecurseSubdirectories = true,
EncryptionProperties = null,
SolidCompression = false,
CompressionMode = RarCompressionMode.Normal,
DictionarySize = RarDictionarySize.Mb__128,
OverwriteMode = RarOverwriteMode.Overwrite,
FilePathMode = RarFilePathMode.ExcludeBaseDirFromFileNames,
FileTimestamps = RarFileTimestamps.All,
AddQuickOpenInformation = Microsoft.VisualBasic.TriState.True,
ProcessHardLinksAsLinks = true,
ProcessSymbolicLinksAsLinks = Microsoft.VisualBasic.TriState.True,
DuplicateFileMode = RarDuplicateFileMode.Enabled,
FileChecksumMode = RarFileChecksumMode.BLAKE2sp,
ArchiveComment = new RarArchiveComment("Hello world!"),
RecoveryRecordPercentage = 0,
VolumeSplitOptions = null,
FileTypesToStore = null
};Console.WriteLine($"Command-line arguments: {command}")
MessageBox.Show(command.ToString())
Using rarExecutor As New RarCommandExecutor(command)
AddHandler rarExecutor.OutputDataReceived,
Sub(sender As Object, e As DataReceivedEventArgs)
Console.WriteLine($"[Output] {Date.Now:yyyy-MM-dd HH:mm:ss} - {e.Data}")
End Sub
AddHandler rarExecutor.ErrorDataReceived,
Sub(sender As Object, e As DataReceivedEventArgs)
If e.Data IsNot Nothing Then
Console.WriteLine($"[Error] {Date.Now:yyyy-MM-dd HH:mm:ss} - {e.Data}")
End If
End Sub
AddHandler rarExecutor.Exited,
Sub(sender As Object, e As EventArgs)
Dim pr As Process = DirectCast(sender, Process)
Dim rarExitCode As RarExitCode = DirectCast(pr.ExitCode, RarExitCode)
Console.WriteLine($"[Exited] {Date.Now:yyyy-MM-dd HH:mm:ss} - rar.exe process has terminated with exit code {pr.ExitCode} ({rarExitCode})")
End Sub
Dim exitcode As RarExitCode = rarExecutor.ExecuteRarAsync().Result
End Usingusing (RarCommandExecutor rarExecutor = new RarCommandExecutor(command)) {
rarExecutor.OutputDataReceived += (object sender, DataReceivedEventArgs e) => {
Console.WriteLine($"[Output] {DateTime.Now:yyyy-MM-dd HH:mm:ss} - {e.Data}");
};
rarExecutor.ErrorDataReceived += (object sender, DataReceivedEventArgs e) => {
if (e.Data != null) {
Console.WriteLine($"[Error] {DateTime.Now:yyyy-MM-dd HH:mm:ss} - {e.Data}");
}
};
rarExecutor.Exited += (object sender, EventArgs e) => {
Process pr = (Process)sender;
RarExitCode rarExitCode = (RarExitCode)pr.ExitCode;
Console.WriteLine($"[Exited] {DateTime.Now:yyyy-MM-dd HH:mm:ss} - rar.exe process has terminated with exit code {pr.ExitCode} ({rarExitCode})");
};
RarExitCode exitcode = rarExecutor.ExecuteRarAsync().Result;
}Explore the complete list of changes, bug fixes, and improvements across different releases by clicking here.
Your contribution is highly appreciated!. If you have any ideas, suggestions, or encounter issues, feel free to open an issue by clicking here.
Your input helps make this Work better for everyone. Thank you for your support! 🚀
This work is distributed for educational purposes and without any profit motive. However, if you find value in my efforts and wish to support and motivate my ongoing work, you may consider contributing financially through the following options:
| Platform | How to Support |
|---|---|
| Become my sponsor on GitHub Contribute any amount you prefer and unlock rewards! |
|
| Support me on Ko-fi Buy me a coffee! |
|
| Become a Patron on Patreon Support my open-source work regularly! |
|
| Make a PayPal Donation Donate any amount you like via PayPal! |
|
| Purchase my software at Envato's CodeCanyon Discover my desktop tools and DevCase Class Library for .NET, an extensive API suite. |
This work relies on the following technologies, libraries or resources:
This software and its associated repository are provided strictly on an "as is" basis, without warranties of any kind, whether express or implied. This includes, but is not limited to, any implied warranties of merchantability, reliability, or fitness for a particular purpose.
The authors and copyright holders assume no liability for any direct, indirect, incidental, or consequential damages—including data loss or system errors—arising from the use, misuse, or inability to use this software. You are solely responsible for determining the appropriateness of using this tool and assume all associated risks.
Furthermore, this project operates entirely independently. The utilization of any third-party libraries or components within this software does not imply any affiliation with, or endorsement or approval by, their respective original authors.
This project is licensed under the Apache License, Version 2.0. See the License file for details.