DinoChiesa / DotNetZip

Library for creating and reading .ZIP files from a .NET Language
Other
120 stars 41 forks source link

Question: Would it be possible to make InternalAddEntry public? #9

Open romerod opened 4 years ago

romerod commented 4 years ago

I would like to merge two zip files without decompressing/recompressing and decrypting/encrypting.

The following spike code does what I want:

var addEntryMethod = typeof(ZipFile).GetMethod("InternalAddEntry", BindingFlags.NonPublic | BindingFlags.Instance);

using (var zip1 = ZipFile.Read(stream1)) using (var zip2 = ZipFile.Read(stream2)) { foreach (var entry in zip2.ToArray()) { entry.FileName = $@"zip2/{entry.FileName}"; addEntryMethod.Invoke(zip1, new object[] { entry.FileName, entry }); //zip1.InternalAddEntry(entry.FileName, entry); }

zip1.Save(@"C:\temp\merged.zip");

}