I'm not sure if this is the right spot but it seems the most active forum so here goes..
I have created a test program in C# and .NET 3.5 which takes an image from a database (in the form of a byte array) and inserts the image into a word document. When I add a new image part to a word document and call imagepart.FeedData(ms) where ms is a MemoryStream loaded from a byte array, the final document contains a 0 byte image and the image appears as a red x in word. If I take the same byte array, write it to a file, and then read it to a file stream and pass it to the FeedData method, the image appears correctly in the word document.
Here is the code I`m currently using....
msImage.Write(bytImage, 0, bytImage.Length);
Does anyone have any idea why this might be happening? Thanks.
Well, I've been unable to find a reason as to why the memorystream doesn't work and the filestream does. Luckily saving the files to a temp directory with filestream and rereading it will work as well.
There is the solution.
ms.Position = 0;
That line should be added between the Save and FeedData calls.