asp.net zip with .net GZipStream - file corrupt

Joined
Mar 31, 2008
Messages
2
Reaction score
0
Hi All,

I need to send the client a zipped file which will contain the contents of a dataset (trying to zip an excel file).

I created a String from the dataest with proper delimeters, then I converted the string to a byte array.

Then I zipped the byte array using GZipStream.

So far, so good (i think).

Next, I am doing the following:


1 Response.ClearContent();
2 Response.ClearHeaders();
3 Response.Clear();
4 //Response.ContentType = "application/x-zip-compressed";
5 Response.ContentType = "application/x-gzip-compressed";
6
7 Response.AddHeader("Content-Disposition", "attachment; filename=" + "excel.xls" + ".zip");
8 Response.AddHeader("Content-Length", byteArr.Length.ToString());
9
10 Response.BinaryWrite(byteArr);
11
12 Response.Flush();
13 Response.End();



The problem is that the zip file is created but it won't open using windows standard compressed zip application. I receive "The Compressed (zipped) Folder is invalid or corrupted".

If I use "FileZip" it opens correctly.

Any ideas why it isn't opening properly with windows standard zip?

Thanks in adnvace !
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top