title: Returning a zipfile from a web api
body: <p>I have built an asp net web api. I need to return a zipfile, as a result of some inner logic. I'm using this code and it works, but the resulting zip file, when unzipped manually, gave me this error "There are data after the end of the payload"</p>
  
  <pre><code> using (ZipFile zip = new ZipFile())
   {
       ...
       zip.Save(di.FullName + "\\" + "Update.zip");
   }
  
  
   string path = Path.Combine(Properties.Settings.Default.PathDisposizioniHTML, "Update.zip");
  
   var response = new HttpResponseMessage(HttpStatusCode.OK);
   var stream = new System.IO.FileStream(path, System.IO.FileMode.Open);
   response.Content = new StreamContent(stream);
   response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
  </code></pre>
  
  <p>This is how i receive the data in a .net console application:</p>
  
  <pre><code>using (Stream output = File.OpenWrite(@"C:\prova\MyFile.zip"))
      using (Stream input = httpResponse.GetResponseStream())
      {
          input.CopyTo(output);
      }
  </code></pre>