title: How to read byte array into FileStream
body: <p>I have an byte array and I want to read the byte array into a FileStream. Below is my sample of code:</p>
  
  <pre><code>string fileName = "test.txt";
  byte[] file = File.ReadAllBytes(Server.MapPath("~/Files/" + fileName));
  FileStream fs = new FileStream();
  fs.ReadByte(file);
  object obj = LoadFile&lt;object&gt;(fs);
  
  public static T LoadFile&lt;T&gt;(FileStream fs)
  {
      using (GZipStream gzip = new GZipStream(fs, CompressionMode.Decompress))
      {
          BinaryFormatter bf = new BinaryFormatter();
          return (T)bf.Deserialize(gzip);
      }
  }
  </code></pre>
  
  <p>In the method above, I have use FileStream to read byte array, but unlucky fs.ReadByte cannot read byte array. Any help please focus on how to Read byte array into a FileStream for using as a parameter in method "LoadFile". Please do not read directly the file into FileStream because the file here is loaded from somewhere else like from database or other source.</p>