title: Issues downloading zip files ASP MVC
body: <p>I am working with an ASP MVC site that zips some files together. It seems to be working but when I try to extract the files I get </p>
  
  <pre><code>An unexpected error is keeping you from copying the file. If you continue the receive this error, you can use the error code to search for help with this problem.
  enter code here
  
  
  Error 0x80004005: Unspecified error
  </code></pre>
  
  <p>7 Zip says CRC failed. File is broken.</p>
  
  <p>It seems that somthing is getting corrupted either when writing or downloading the zip. I have tried 2 different methods to download the file with the same result.</p>
  
  <pre><code>public ActionResult DownloadFiles()
  {
      List&lt;string&gt; files = GetFileList();
      using (ZipFile zip = new ZipFile())
      {
          foreach (string file in files)
              zip.AddFile(file, string.Empty);
  
          MemoryStream output = new MemoryStream();
          zip.Save(output);
          return File(output.ToArray(), "application/zip", "file.zip");
      }
  }
  
  public void DownloadFiles()
  {
      List&lt;string&gt; files = GetFileList();
      using (ZipFile zip = new ZipFile())
      {
          foreach (string file in files)
              zip.AddFile(file, string.Empty);
  
          Response.Clear();
          Response.BufferOutput = false;
          Response.ContentType = "application/zip";
          Response.AddHeader("content-disposition", "attachment; filename=file.zip");
          zip.Save(Response.OutputStream);
          Response.End();
      }
  }
  
  &lt;button onclick="fn_DownloadFiles()"&gt;Download Selected&lt;/button&gt;
  
  function fn_DownloadSelectedFiles() 
  {
      window.location.href = "/Files/DownloadFiles"
  }
  </code></pre>
  
  <p>Any reason why the files would be getting corrupted?</p>
  
  <p>I tried this too</p>
  
  <pre><code>public ActionResult DownloadFiles(string filePaths)
  {
      List&lt;string&gt; files = GetFileList();
      using (MemoryStream zipStream = new MemoryStream())
      using (ZipArchive zipArchive = new ZipArchive(zipStream, ZipArchiveMode.Create, true))
      {
          foreach (string file in files)
          {
              ZipArchiveEntry entry = zipArchive.CreateEntry(file, CompressionLevel.Fastest);
  
              using (FileStream fileStream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
              using (Stream entryStream = entry.Open())
                  fileStream.CopyTo(entryStream);
          }
          return File(zipStream.ToArray(), "application/zip", "files.zip"));
      }
  }
  </code></pre>
  
  <p>With this I get Windows cannot open the folder. The compressed (zipped) Folder is invalid.</p>