title: DotNetZip Saving to Stream
body: <p>I am using DotNetZip to add a file from a <code>MemoryStream</code> to a zip file and then to save that zip as a <code>MemoryStream</code> so that I can email it as an attachment. The code below does not err but the <code>MemoryStream</code> must not be done right because it is unreadable.  When I save the zip to my hard drive everything works perfect, just not when I try to save it to a stream.</p>
  
  <pre><code>using (ZipFile zip = new ZipFile())
  {
  var memStream = new MemoryStream();
  var streamWriter = new StreamWriter(memStream);
  
  streamWriter.WriteLine(stringContent);
  
  streamWriter.Flush();      
  memStream.Seek(0, SeekOrigin.Begin);
  
  ZipEntry e = zip.AddEntry("test.txt", memStream);
  e.Password = "123456!";
  e.Encryption = EncryptionAlgorithm.WinZipAes256;
  
  var ms = new MemoryStream();
  ms.Seek(0, SeekOrigin.Begin);
  
  zip.Save(ms);
  
  //ms is what I want to use to send as an attachment in an email                                   
  }
  </code></pre>