title: Creating a ZIP archive in memory using System.IO.Compression
body: <p>I'm trying to create a ZIP archive with a simple demo text file using a <code>MemoryStream</code> as follows:</p>
  
  <pre><code>using (var memoryStream = new MemoryStream())
  using (var archive = new ZipArchive(memoryStream , ZipArchiveMode.Create))
  {
      var demoFile = archive.CreateEntry("foo.txt");
  
      using (var entryStream = demoFile.Open())
      using (var streamWriter = new StreamWriter(entryStream))
      {
          streamWriter.Write("Bar!");
      }
  
      using (var fileStream = new FileStream(@"C:\Temp\test.zip", FileMode.Create))
      {
          stream.CopyTo(fileStream);
      }
  }
  </code></pre>
  
  <p>If I run this code, the archive file itself is created but <em>foo.txt</em> isn't.</p>
  
  <p>However, if I replace the <code>MemoryStream</code> directly with the file stream, the archive is created correctly:</p>
  
  <pre><code>using (var fileStream = new FileStream(@"C:\Temp\test.zip", FileMode.Create))
  using (var archive = new ZipArchive(fileStream, FileMode.Create))
  {
      // ...
  }
  </code></pre>
  
  <p>Is it possible to use a <code>MemoryStream</code> to create the ZIP archive without the <code>FileStream</code>?</p>