-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Labels
fixed in nextBug not present main branch, but it has not been released yetBug not present main branch, but it has not been released yet
Description
Steps to reproduce
With the current library from Nuget (1.2), I get a corrupt archive, if I use this code:
If I dont have CompressionMethod.Stored, then the archive works, but the uncompressed files are always few bytes bigger than the original files. I need the files to be exactly the same (original size = size of file in ZIP archive).
I have fixed this whole thing for myself before (see my older issue), but in 1.2, this still seems to be flawed.
Best
Martin
public ZipWriter(string filename)
{
_sziFilename = filename;
FileStream fsOut = File.Create(_sziFilename);
_zipStream = new ZipOutputStream(fsOut);
_zipStream.SetLevel(0); //0-9, 9 being the highest level of compression
}
public void AddFileToZip(string filenameInZip, MemoryStream memTile)
{
memTile.Position = 0;
DateTime creationTimeUtc = DateTime.Now;
string entryName = filenameInZip;
entryName = ZipEntry.CleanName(entryName); // Removes drive from name and fixes slash direction
var newEntry = new ZipEntry(entryName)
{
DateTime = creationTimeUtc,
CompressionMethod = CompressionMethod.Stored,
Size = memTile.Length,
};
_zipStream.PutNextEntry(newEntry);
// Zip the file in buffered chunks
// the "using" will close the stream even if an exception occurs
byte[] buffer = new byte[4096];
StreamUtils.Copy(memTile, _zipStream, buffer);
_zipStream.CloseEntry();Expected behavior
ZIP archive should be OK
Actual behavior
ZIP archive corrupt
Version of SharpZipLib
1.2.0
Obtained from (only keep the relevant lines)
- Package installed using NuGet
Metadata
Metadata
Assignees
Labels
fixed in nextBug not present main branch, but it has not been released yetBug not present main branch, but it has not been released yet