system.io.compression

ZipArchive gives Unexpected end of data corrupted error

六月ゝ 毕业季﹏ 提交于 2019-12-01 02:49:53
I'm trying to create a zip stream on the fly with some byte array data and make it download via my MVC action. But the downloaded file always gives the following corrupted error when opened in windows. And this error when I try to xtract from 7z But note that the files extracted from the 7z is not corrupted. I'm using ZipArchive and the below is my code. private byte[] GetZippedPods(IEnumerable<POD> pods, long consignmentID) { using (var zipStream = new MemoryStream()) { //Create an archive and store the stream in memory. using (var zipArchive = new ZipArchive(zipStream, ZipArchiveMode.Create,