what is the best method of concatenating a series of binary files into one file?

Posted by Andrew on Stack Overflow See other posts from Stack Overflow or by Andrew
Published on 2010-05-24T13:53:39Z Indexed on 2010/05/24 14:01 UTC
Read the original article Hit count: 201

Filed under:

hello everyone

i have a series of PDF byte arrays in a arraylist files that i wish to concatenate into one file, currently when the PDF application trys to open the file is it corrupted:

       foreach (byte[] array in files)
        {

            using (Stream s = new MemoryStream(downloadbytes))
            {

                    s.Write(array, 0, array.Length);

            }



        }

downloadbytes is the resultant concatenated array of bytes below is another implementation which also failed

      foreach (byte[] array in files)
        {


            System.Buffer.BlockCopy(array, 0, downloadbytes, offset, array.Length);

            offset += array.Length;



        }

any pointers?

© Stack Overflow or respective owner

Related posts about c#