This project is read-only.

SevenZipExtractor constructor throws exception in CheckSignature

May 8, 2012 at 12:48 AM
Edited May 8, 2012 at 12:49 AM

I added a header to my zipped files before the archive starts.  If I open the file in notepad, I can see the correct header.  If I open the file in winrar, it shows me the contents of the archive.  Passing the stream to the SevenZipExtractor constructor throws an exception with the following message:

"The stream is invalid or no corresponding signature was found."

I just removed the line which resets the stream position:

stream.Seek(0, SeekOrigin.Begin);

I read off the header and pass the stream to the SevenZipExtractor constructor and it now works.  When googling for this issue, I saw others who had the same problem, so I just wanted to share my hacky solution.  Although, this now behaves as I would have expected, so maybe it's not that hacky.  I might also need to set the out variable "offset" to the current stream position instead of 0, but I'm not sure how to properly test it and it seems to work without changes.

It seems like the original intent of CheckSignature was to read through the file until it found the start of the archive, but was never fully implemented.  There is even a region marked "Check if it is an SFX archive or a file with an embedded archive."

Mar 20, 2013 at 12:54 AM
I'm not positive, I've download the latest 0.64 through NuGet, but seems to have the constructor bug you mention here. I press F12 to bring up the source, and it shows I've got a ctor with a string path, like I am expecting. However, I get the error here. Is there a new update I can download?