title: ASP.NET Create zip file for download: the compressed zipped folder is invalid or corrupted
body: <pre><code>string fileName = "test.zip";
  string path = "c:\\temp\\";
  string fullPath = path + fileName;
  FileInfo file = new FileInfo(fullPath);
  
  Response.Clear();
  Response.ClearContent();
  Response.ClearHeaders();
  Response.Buffer = true;
  Response.AppendHeader("content-disposition", "attachment; filename=" + fileName);
  Response.AppendHeader("content-length", file.Length.ToString());
  Response.ContentType = "application/x-compressed";
  Response.TransmitFile(fullPath);
  Response.Flush();
  Response.End();
  </code></pre>
  
  <p>The actual zip file c:\temp\test.zip is good, valid, whatever you want to call it. When I navigate to the directory c:\temp\ and double-click on the test.zip file; it opens right up.</p>
  
  <p>My problem seems only to be with the download. The code above executes without any issue. A file download dialog is presented. I can chose to either save or open. If I try to open the file from the dialog, or save it and then open it. I get the following dialog message:</p>
  
  <p>The Compressed (zipped) Folder is invalid or corrupted.</p>
  
  <p>For Response.ContentType I've tried:</p>
  
  <p>application/x-compressed 
  application/x-zip-compressed 
  application/x-gzip-compresse
  application/octet-stream
  application/zip</p>
  
  <p>The zip file is being created with some prior code (that I'm sure is working fine due to my ability to open the created file directly) using: Ionic.zip</p>
  
  <p><a href="http://www.codeplex.com/DotNetZip" rel="nofollow noreferrer">http://www.codeplex.com/DotNetZip</a></p>