The Compressed (zipped) Folder is invalid or corrupted

Jan 28, 2010 at 8:06 PM


So I'm able to download a zip file to my machine, but when I try to extract it with the Windows extraction tool I get the following error: "The Compressed (zipped) Folder is invalid or corrupted". But I am able to extract with WinRAR. It's also worth noting everytime I flush to the screen and download I get the following exception message thrown in the background (not on the page):

Exception of type 'System.OutOfMemoryException' was thrown. (I can still download the file despite the background exception)



        Dim zippedFolderPath As String = ConfigurationManager.AppSettings("AccredAppDocumentLocation") & "controls\"

        Response.BufferOutput = False

        Dim enc As Ionic.Zip.EncryptionAlgorithm = Ionic.Zip.EncryptionAlgorithm.None

        Dim c As System.Web.HttpContext = System.Web.HttpContext.Current

        Dim archiveName As String = String.Format("archive-{0}.zip", DateTime.Now.ToString("yyyy-MMM-dd-HHmmss"))
        Response.ContentType = "application/zip"
        Response.AddHeader("content-disposition", "filename=" + archiveName)

        Using zip As New ZipFile()

            zip.Encryption = enc

        End Using

Also, very important, I am able to get the above code to work just fine with no errors on my other websites on my server. For instance, this problem ONLY occurs on my Intranet website. The only difference I can gather is that the websites that work run Forms authentication where as this problem is occurs on the Intranet website which is runnig Windows authentication. Not sure if that matters.....

Any advice?

Thank you


Jan 30, 2010 at 6:27 PM

There have been other out-of-memory errors reported.  If you are using v1.9 of DotNetZip, make sure to get v1.9.1.2 (the latest); it fixes a problem that could lead to an out-of-memory error.

If you are not on v1.9, then I don't know what the problem is, but it sure looks like the difference between websites is leading to a differently-constructed zip file. 

If I were you I would track down that out-of-memory exception first. I don't know what you mean by saying that the exception is "thrown in the background."  

I would track it down by putting a try...catch in your code and stepping through it with a debugger.   Only do this after moving to v1.9.1.2.