I have the following code:
using (var ms = new MemoryStream())
this.WriteProjectConfig(this.ProjectConfig, ms); //provides some data in the memory stream
var entry = this.ZipFile[CONFIG_FILE_NAME];
if (entry != null)
//!! this.ZipFile.Save(pathAndFilename); //workaround, otherwise file content in zip might be zero bytes
This code might become executed several times, without disposing/re-initializing the ZipFile object. The first time this runs (and the file is already in the zip, thus is being removed and re-added already on the first attempt), this works well.
The second++ time this code in executed it runs without exeception, but the file in the zip is of 0 bytes length, though the memory stream contained something like 10000 bytes of data.
But this data somehow gets lost. The workaround is to do a ZipFile.Save() after removing the entry and again after adding it.
I use Ionic.Zip.Reduced Version 220.127.116.11 (the latest).
If this a bug in the library?