title: Convert Zip File to byte[] and byte[] to zip file
body: <p>I try to convert zip file to byte[] and write it to a text file.</p>
  
  <pre><code>int BufferSize=65536;
  private void button1_Click(object sender, EventArgs e)
  {
      DialogResult re = openFileDialog1.ShowDialog();
      if (re == DialogResult.OK)
      {
          string fileName = openFileDialog1.FileName;
          try
          {
              byte[] bytes = File.ReadAllBytes(fileName);
              File.WriteAllBytes(@"F:\Info.txt", bytes);
          }
          catch (Exception) { }
      }
  }   
  </code></pre>
  
  <p>Then I try to convert those byte to zip file. But I can't do it.</p>
  
  <p>My code is here:</p>
  
  <pre><code>private void button2_Click(object sender, EventArgs e)
  {
  
      DialogResult re = openFileDialog1.ShowDialog();
      if (re == DialogResult.OK)
      {
          string fileName = openFileDialog1.FileName;
          try
          {
              byte[] bytes = File.ReadAllBytes(fileName);
              using (var mstrim = new MemoryStream(bytes))
              {
                  using (var inStream = new GZipStream(mstrim, CompressionMode.Compress))
                  {
                      using (var outStream = File.Create("Tax.Zip"))
                      {
                          var buffer = new byte[BufferSize];
                          int readBytes;
                          while ((readBytes = inStream.Read(buffer, 0, BufferSize)) != 0)
                          {
                              outStream.Write(buffer, 0, readBytes);
                          }
                      }
                  }
              }
          }
          catch (Exception) { }
      }
  }
  </code></pre>
  
  <blockquote>
    <p>Error:File Mode not valid.</p>
  </blockquote>
  
  <p>What File Mode is needed and how can I accomplish what I described?</p>