Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
romerod opened this issue Oct 13, 2020 · 0 comments
Open

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

romerod opened this issue Oct 13, 2020 · 0 comments

Comments

@romerod
Copy link

romerod commented Oct 13, 2020

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");

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant