C# program with WinRAR

For this you probably want to use unrar.dll which is the library distributed by RarLabs, the people who make Winrar. It contains all the functionality of WinRAR exposed as a COM interface. I used it recently in a project and it is quite good, exposes methods for opening and browsing archives, as well as compression and decompression.

http://www.rarlab.com/rar_add.htm scroll down to "UnRAR.dll UnRAR dynamic library for Windows software developers."

It comes with a really good set of examples including browsing an archive and API documentation.


Yes, I'm ressurrecting a completely dead question here, but I've not seen anyone put up the exact answer you(and until 20 minutes ago I too) want, so let me put 2 and 2 together:

Command line Usage: rar.exe a <target .rar file> <file to rar> {<more files>}
You can make more complicated names, like ones containing spaces, by putting quotation marks around the names. The program you'll probably want is thus:

string targetArchiveName = "archive.rar",
targetFile = "testFile.txt";
ProcessStartInfo startInfo = new ProcessStartInfo("WinRAR.exe");
startInfo.WindowStyle = ProcessWindowStyle.Maximized;
startInfo.Arguments = string.Format("a \"{0}\" \"{1}\"",
                      targetArchiveName, targetFile);
try
{
  // Start the process with the info we specified.
  using (Process exeProcess = Process.Start(startInfo))
  {
    exeProcess.WaitForExit();
  }
}
catch
{
  {
    MessageBox.Show("Error Open");
  }
}

What about this one:
http://nunrar.codeplex.com/

Tags:

C#