mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-03 21:23:38 +00:00
NUnrar.InvalidRarFormatException: 'Invalid Rar Header: 134' #336
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @martinsolovey on GitHub (Dec 12, 2018).
Hi,
First of all, thank you for such a complete library, I hope I can sort out here the issues and take advantage of it.
So I have a winRar made .rar file, perfectly fine which I can decompress with winRar without problems.
The code that I am running is the following:
RarArchive file = RarArchive.Open(_fileName.FullName);
foreach (RarArchiveEntry rarFile in file.Entries)
{
string path = Path.Combine(_pathToExtract, rarFile.FilePath);
using (FileStream output = File.OpenWrite(path))
rarFile.WriteTo(output);
}
But when it tries to access the Entires, I get that invalid header exception, I am actually lost on how to move on, because the file is .rar legit.
Hope you can help me down here.
Thanks!
@adamhathcock commented on GitHub (Dec 13, 2018):
Are you actually using NUnrar still? Please use Sharpcompress instead. Usage is similar.
It could be a RAR5 file format which NUnrar definitely doesn't know how to deal with.
@martinsolovey commented on GitHub (Dec 13, 2018):
Hi Adam,
Thanks again for your time, hope I can get this working.
Sorry, I didn't mean to post the Nunrar, I just miss-copied probably, been the whole day trying out any api that I found out there, none has worked so far. I also tried with SharpCompress, I'll post down here my SharpCompress code.
var dir = new DirectoryInfo(_pathToExtract);
The exception I get is the following:
System.NotSupportedException: 'Unknown header: 561144146'
It is highly possible that my winrar version is just not supported, is that possible? how can I get my winrar to generate a sharpcompress supported rar output?
Thanks again man, I really appreciate you taking the time to check this out and respond.
@adamhathcock commented on GitHub (Dec 13, 2018):
What version are you using? That exception doesn't seem to exist in the code base anymore. The full stack trace might help too
@martinsolovey commented on GitHub (Dec 13, 2018):
I just did some version double check, and on a phantom context it now works lol.
I am now fighting a bit with extracting onto a path where files/directories should be replaced.
Basically the behavior I need is a normal ExtractAll with override (for both directories and files) do you happen to have any additional class there that might work like that?
I tried ExtractAllEntries() from Archive, but it doesn't seem to do the trick.
@martinsolovey commented on GitHub (Dec 13, 2018):
Actually Adam, I just made it work under my specs, I share here my wrapper so you can include it in your api if you want.
Thanks a lot for your good will!