I am using ICSharpCode.SharpZipLib.Zip to compress the files and folders and pass it as memorystream using response.Binary write.
Here is my code:
MemoryStream df= new MemoryStream();
ZipOutputStream s = new ZipOutputStream(df);
s.SetLevel(9);
byte[] data = (byte[])file.OpenBinary();
s.Write(data, 0, data.Length);
s.Finish();
s.Close();
byte[] outBuf = df.GetBuffer();
Response.Expires = 0;
Response.Buffer = true;
Response.ClearContent();
Response.AddHeader("content-disposition", "inline; filename="out.zip");
Response.ContentType = "application/zip";
Response.BinaryWrite(outBuf);
HttpContext.Current.ApplicationInstance.CompleteRequest();
When I try to open the out.zip file, it is saying that the zip file is either corrupted or damaged, and the crc value is showing as 000000.
What is the solution for this? Why is this error is occurring?