I’m having problems with one customer who repeatedly gets this error when uploading a zip file which is unzipped in memory with ChilKatZip.
OpenFromMemory: Failed to get end-of-directory record.
I also get the same error, but if I extract and then re-zip I get no problems. Im not sure what their zip program is, but I wondered if you have seen this error before (couldnt find anything on your site) and if you have any info that might help.
You’re the 3rd customer to recently have this problem. It’s because you wrote the zip using a .NET memory stream and you need to close it first before trying to use the data. The error indicates that the Zip ended prematurely — and it did. That’s because the remainder of the memory stream was not yet flushed. Closing it will flush the stream, and then you can open the zip from memory. This is something to remember in general: whenever using System.IO.MemoryStream, you must close it (or flush it) before using the data written. This is a real pitfall because the bug can escape testing. When forgetting to flush the memory stream, the code may or may not work — it all depends on chance (i.e. whether the buffer contains unflushed data). Thus, you may find it works on one computer but not another, or that sometimes the code works, and sometimes not.