EncodeSingleFile Creates Corrupted Archives


The following code snippet successfully produces an archive:
    Dim d As New Dictionary(Of SevenZSharp.CompressionFormat, SevenZSharp.ICompressionEngine)
    d.Add(CompressionFormat.SevenZ, New SevenZSharp.Engines.DelegationEngine)
    Dim x As New SevenZSharp.Encoders.DelegationEncoder(d)
    ' This would work normally: x.EncodeFromDirectory("C:\Documents and Settings\Luke\Desktop\Old Desktop Crap", "C:\Documents And Settings\Luke\Desktop\test.7z")
    x.EncodeSingleFile("C:\Documents And Settings\Luke\Desktop\n582421010_9432.jpg", "C:\Documents And Settings\Luke\Desktop\test.7z")
However, instead of containing my jpeg (or whatever other file, I have tried with all sorts), the archive contains a file named test (same as the archive minus the file extension) and is about the size of what the compressed jpeg should be.
This happens with all three of the encoders, not just the DelegationEncoder. Interestingly enough, EncodeFromDirectory works perfectly fine.
See the attached archive. I've gotten a similar archive using the command line version of 7-Zip itself in the past when I was passing paths incorrectly as arguments; maybe my code is malformed, or the code in 7zSharp is passing things the way I did.

file attachments


HackAttack wrote Feb 26, 2009 at 1:51 AM

Worth mentioning, if you extract the extensionless "test" file from the archive and add a ".jpg" extension, you will be able to view it. It's an old picture of me.

wrote Feb 14, 2013 at 2:52 AM