title: Central Directory corrupt error in ziparchive
body: <p>In my c# code I am trying to create a zip folder for the user to download in the browser. So the idea here is that the user clicks on the download button and he gets a zip folder.</p>
  <p>For testing purpose I am using a single file and zipping it but when it works I will have multiple files.</p>
  <p>Here is my code</p>
  <pre><code>var outPutDirectory = AppDomain.CurrentDomain.BaseDirectory;
  string logoimage = Path.Combine(outPutDirectory, &quot;images\\error.png&quot;); // I get the file to be zipped
  
  HttpContext.Current.Response.Clear();
  HttpContext.Current.Response.BufferOutput = false;
  HttpContext.Current.Response.ContentType = &quot;application/zip&quot;;
  HttpContext.Current.Response.AddHeader(&quot;content-disposition&quot;, &quot;attachment; filename=pauls_chapel_audio.zip&quot;);
  
  
  using (MemoryStream ms = new MemoryStream())
       {
            // create new ZIP archive within prepared MemoryStream
            using (ZipArchive zip = new ZipArchive(ms))
               {
                      zip.CreateEntry(logoimage);
                      // add some files to ZIP archive
  
                      ms.WriteTo(HttpContext.Current.Response.OutputStream);
               }
       }
  </code></pre>
  <p>When I try this thing it gives me this error</p>
  <blockquote>
  <p>Central Directory corrupt.</p>
  <p>[System.IO.IOException] = {&quot;An attempt was made to move the position before the beginning of the stream.&quot;}</p>
  </blockquote>
  <p>Exception occurs at</p>
  <blockquote>
  <p>using (ZipArchive zip = new ZipArchive(ms))</p>
  </blockquote>
  <p>Any thoughts?</p>