For a project I’ll probably dedicate a post on this blog to in the future, I needed a ZIP library for Silverlight. After asking around on twitter (@rickvdbosch) I was pointed towards the SharpZipLib port on Codeplex, found on http://slsharpziplib.codeplex.com.
Basically what I wanted to do was replace a file inside the ZIP file with my version of that file. The file was located in a specific folder inside the ZIP and could be found by either iterating through the ZipEntries in the ZIP, or by getting it based on its name. But deleting the file gave me a ZipException with the error message ‘Cannot find entry to delete’. When I added a file myself, it could be deleted just fine, but the ZIP just did not want the existing file to be removed.
After searching around on some forums, I found there was a new development version of SharpZipLib which might solve the problem. But that was the full version, not the Silverlight port. So I searched around some more and found something about subfolders.
As it turns out, and existing file can be deleted when it is located in the root of the ZIP. Apparently there’s some bug keeping you from deleting files in subfolders. Anyhow, moving the file I need updated to the root of the ZIP solved my problem for me (for now), so I can continue my project. If and when slsharpziplib is updated in the future, I’ll have a look if they solved this in the port too…
Hope this helps.