Would you be able to use DotNetZip? I find it easier to use much of the time, I was able to get ZipEntry comments working, see below.
Using DotNetZip:
using (ZipFile zip = new ZipFile(__zipName))
{
string testFile = @"...";
ZipEntry newEntry = zip.AddFile(testFile);
newEntry.Comment = "test";
zip.Save();
}
using (ZipFile zip = new ZipFile(__zipName))
{
Console.WriteLine(zip[0].Comment);
}
It appears that SharpZipLib doesn't fully support ZipEntry.Comment
, see @DRMacIver answer for good research there, I've also tried multiple ways and cannot figure it out (I am able to set the comment and save, but when I read it again it is null).
I don't know why it doesn't work, but I would guess that it might be because standard zifiles does not support comments for Files, only one comment for the whole zip file. So I'm thinking they might be extending zip to support that, maybe they never finished it or never tested it.
Unrelated but I'll mention that I've done tests previously and SharpZipLib was able to achieve slightly better compression, but the ease of use of DotNetZip still made it a better solution for me.
I have not tried using SharpZipLib to read a zip file created with DotNetZip with working comments to see if it might be a problem with reading it or writing it (I am curious about this)