This project is read-only.

Compress file with dotnetzip, and when open it is corrupted

Jan 9, 2013 at 2:06 PM
Edited Jan 9, 2013 at 2:18 PM

I create a fileresult in a controller using dotnetzip from a [] array like this

byte[] fileBytes =array
MemoryStream outputStream = new MemoryStream();                       
using (ZipFile zipFile = new ZipFile())
zipFile.AddEntry(returnFileName, fileBytes);
outputStream.Position = 0;
return File(outputStream, "application/zip", returnFileName + ".zip"); 

When i unzip the file and open it instead of the original file, the content are extrange caracters like this ones:


The filebytes is correct because i have an option to download the file without zipping so i return in that case something like this,And the file is open correctly. :

return File(fileBytes, "text/html", returnFileName);

Another thing if i overwrite the filebytes with this:

fileBytes = Encoding.ASCII.GetBytes("abcdefghi");

The file after unzipping is load correctly