I am running across an issue and I'm not complete sure here. I have an image that I converted into a byte array. Now, I want to add to that byte array. Let's say I want to add an "I" for image on to the beginning of the byte array. Or lets say I have a statement of "Hello World" that I want to add.
I currently have it setup like this:
byte aryTemp = new byte[aryByteFirst.Length + aryByteSecond.Length];
System.Buffer.BlockCopy(aryByteFirst, 0, aryTemp, 0, aryByteFirst.Length);
System.Buffer.BlockCopy(aryByteSecond, 0, aryTemp, aryByteFirst.Length, aryByteSecond.Length);
catch (Exception ex)
This will perform the BlockCopy and the aryTemp array is properly sized. However, if I have the example of adding an "I" which is a byte of 73 to the beginning to an image that was converted into a byte array. It is properly sized and I see the "I" byte of 73 in the beginning and all the other image bytes after.
The problem is if I try to convert it to a memorystream and try to load the image I get a "Parameter is invalid".
If I instead perform a File.WriteAllBytes of aryTemp to a file and try to load the image from the file. I then get an "Out of Memory" error.
How can I perform this action then?
Any information on this would be very much appreciated!