6
Vote

RAR5 format support

description

The current version of the SharpCompress library thows an exception while extracting a file with a RAR5 format.


An unhandled exception of type 'SharpCompress.Common.InvalidFormatException' occurred in SharpCompress.dll

Additional information: Invalid Rar Header: 225


It would be nice if this format could be supported.

Thanks in advance,
StannieV

Code that produced the exception:
using System;
using System.IO;
using SharpCompress.Reader;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            const string path = @"C:\temp\Test2";

            if (Directory.Exists(path))
                Directory.Delete(path, true);   
            
            Directory.CreateDirectory(path);

            using (Stream stream = File.OpenRead(@"C:\Temp\Test2.rar")) //Test2.rar is a RAR5 format file
            {
                using (var reader = ReaderFactory.Open(stream))
                {
                    while (reader.MoveToNextEntry())
                    {
                        var entry = reader.Entry;
                        if (!entry.IsDirectory)
                        {
                            string fullFileName = Path.Combine(path, entry.FilePath);
                            using (var output = File.OpenWrite(fullFileName))
                            {
                                using (var entryStream = reader.OpenEntryStream())
                                {
                                    entryStream.CopyTo(output);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

file attachments

comments

martin1m wrote Jun 30, 2015 at 6:16 PM