title: Append byte array to pdf file c# asp.net using FileStream
body: <p>I am working in asp.net web application. I am trying to append byte array to pdf file using FileStream and want result as pdf file containing all byte arrays. But getting only last byte array saved in pdf. I don't want to use any external library.</p>
  
  <p>Here is my code for appending bytes :</p>
  
  <pre><code>public void AppendByteToFile(byte[] renderedBytes)
  {
          string path = Server.MapPath("~/PrintImages/file1.pdf");
          var stream = new FileStream(path, FileMode.Append);
          stream.Seek(0, SeekOrigin.End);
          if (stream.Length==stream.Position)
          {
              stream.Write(renderedBytes, 0, renderedBytes.Length);
              stream.Close();
          }
  }   
  </code></pre>
  
  <p>where <code>rendereBytes</code> is rdlc object of local report rendered to pdf as follows </p>
  
  <pre><code>byte[] renderedBytes = report.Render("PDF", deviceInfo);
  </code></pre>
  
  <p>Thank you</p>