What is the best method of concatenating a series of binary files into one file?
<p>I have a series of PDF byte arrays in a arraylist files that i wish to concatenate into one file,
<br />Currently when the PDF application tries to open the file is it corrupted:</p>

<pre><code>foreach (byte[] array in files)
{
    using (Stream s = new MemoryStream(downloadbytes))
    {
        s.Write(array, 0, array.Length);
    }
}
</code></pre>

<p>downloadbytes is the resultant concatenated array of bytes below is another implementation which also failed</p>

<pre><code>foreach (byte[] array in files)
{
    System.Buffer.BlockCopy(array, 0, downloadbytes, offset, array.Length);
    offset += array.Length;
}
</code></pre>

<p>any pointers?</p>
