The archive is either in unknown format or damaged

May 5, 2009 at 9:11 PM
Hi,

I'm trying to use DotNetZip to create a simple zip file in ASP.NET, but it's not working on IE, it's only working on Firefox. I did some research to see if somebody else was having the same problem, but didn't find anything.
The code that I'm using is here:

Response.Clear()

Response.ContentType =

"application/zip"

 

Response.AddHeader(

"content-disposition", "filename=file.zip")

 

zip.AddFile(HttpRuntime.AppDomainAppPath &

"test1.txt")

 

zip.Save(Response.OutputStream)

Response.End()

I'm using the latest version of DotNetZip, I just downloaded it yesterday.

Please advice.....

Thank you!


 

Coordinator
May 6, 2009 at 11:09 AM
Maybe you are seeing this IE-specific problem ? 
http://stackoverflow.com/questions/774761/writing-out-a-zip-file-doesnt-work-in-ie7

May 6, 2009 at 1:26 PM
Hi,
thanks for your reply! I tried that but it doesn't work either. It creates the zip file, but when I click on it to open it I get the error saying "the compressed (zipped) folder is invalid or corrupted".
Please advice....
Thank you!
May 6, 2009 at 2:43 PM
Hi,
I fixed it, I took out the Response.End() and it works perfectly now.
Thanks!
Coordinator
May 6, 2009 at 4:18 PM
Edited Jul 23, 2009 at 11:20 AM

This is a good example: 
http://cheeso.members.winisp.net/DotNetZipHelp/Example-ASPNET.htm

I think the Response.End() should be used carefully.  See stackoverflow question 1087777.

Also, in your code I saw neither a Close/Dispose nor a Using clause for the ZipFile.  You should use one or the other. 

Can you try employing a using() clause and also ending the response properly?  That is a more correct way of doing it, and will result in streams being closed properly.

I am not sure why Firefox would have different results from IE, but it may have to do with how the different browsers handle the http protocol when the OutputStream is not explicitly closed on the server side.


Jul 23, 2009 at 8:04 AM

hi

i am using FireFox to download zip file .i download the file but when i try to Extract it....it gives Error

The archive is either in unknown format or damaged 

this error is coming only when i use Firefox to download ,but this error is not coming when i use Google Chromo or IE(Internet Explorer) to download


Coordinator
Jul 23, 2009 at 11:22 AM
Edited Jul 23, 2009 at 11:38 AM

the normal way to use the forums is to open a new thread when you have a new question, instead of resurrecting an old thread and attaching a new question to it.

Can you open a new thread please?

Maybe it sounds like a hassle, but it makes it much easier for people who answer questions and also people who search later.