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

Fix exception from deleting a directory ZipEntry in a ZipFile #295

merged 1 commit into from Jan 3, 2019


None yet
2 participants
Copy link

benleedom commented Dec 18, 2018

ZipFile.FindExistingUpdate(ZipEntry) would always return -1 for directory ZipEntrys due to using GetTransformedFileName on all ZipEntrys. As a result, ZipFile.Delete(ZipEntry) would always throw an exception when passed a directory ZipEntry. The fix is to call GetTransformedDirectoryName for directory ZipEntrys.

I updated the test AddAndDeleteEntries in ZipFileHandling.cs to add and delete a directory; this test failed without the change to ZipFile.FindExistingUpdate.

I believe issue #290 is related.

I certify that I own, and have sufficient rights to contribute, all source code and related material intended to be compiled or integrated with the source code for the SharpZipLib open source product (the "Contribution"). My Contribution is licensed under the MIT License.


This comment has been minimized.

Copy link

piksel commented Jan 3, 2019

So, the consequence of this bug is that the entry name ends with a slash when created with ZipFile.AddDirectory, but not when it's searched for by ZipFile.Delete (which of course means it will not find it).

Test looks good. I'll try to release a bugfix update with this commit soon.

@piksel piksel merged commit 0269465 into icsharpcode:master Jan 3, 2019

1 check passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment