1

I need to extract a splitted rar-file (r00, r01, r02,...) in C#.

The only thing I've found that might be useful, is sevenzipsharp. I cannot find an example of what I'm trying to do though.

Someone said "docs available at https://archive.codeplex.com/?p=sevenzipsharp", but that dosen't really help since I can't find any examples there.

I know that everything would be a lot easier if I use a different compression format, but I'm not responsible for the generation of the zip files so that is unfortunately not an option.



* UPDATE 01/17/2019 *

I tried:

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            // Toggle between the x86 and x64 bit dll
            var path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), Environment.Is64BitProcess ? "x64" : "x86", "7z.dll");
            SevenZip.SevenZipBase.SetLibraryPath(path);

            using (var file = new SevenZipExtractor(@"F:\ziptest\test.part1.rar"))
            {
                file.ExtractArchive(@"F:\dav\");
            }
        }
    }
}

But that gives me an error, when calling "ExtractArchive":

An unhandled exception of type 'SevenZip.SevenZipArchiveException' occurred in SevenZipSharp.dll

Additional information: Invalid archive: open/read error! Is it encrypted and a wrong password was provided?



* UPDATE 01/20/2019 *

I ended up using the solution provide here: Unrar an archive in C#

I modified the switch parameters so that WinRar runs in the background without opening any windows.

If someone do come up with a solution to my problems with SevenZipSharp I would still like to know, as it is a more "clean" code.

doglio
  • 11
  • 4
  • 1
    If you read the link you provided, it says `See SevenZipTest/Program.cs for simple code examples; SevenZipTestForms is the GUI demo application.` – MineR Jan 17 '19 at 01:17

1 Answers1

0

The codeplex site has a discussion forum that shows several github forks. I followed one to this sample: https://github.com/squid-box/SevenZipSharp/blob/dev/SevenZip.Tests/SevenZipExtractorTests.cs#L64 which suggests that you just need to pass the first volume to the SevenZipExtractor constructor.

using (var extractor = new SevenZipExtractor(@"TestData\multivolume.part0001.rar")) {
    extractor.ExtractArchive(OutputDirectory);
}
Eugene Marcotte
  • 751
  • 8
  • 21