Click here to Skip to main content
15,902,778 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
While i am using memory stream i had an error namely(parameter is not valid)
public Image byteArrayToImage(byte[] byteArrayIn)
{
MemoryStream ms = new MemoryStream(byteArrayIn);
// i got error hereinafter
Image returnImage = Image.FromStream(ms);
return returnImage;
}
Posted

What type of file are you retrieving? The Image class only works for the Bitmap(bmp) and Windows Metafile(wmf) file formats. My guess is the file you are retreiving is not one of these two types of files. Another consideration is the file could be corrupted or the query is returning null.
 
Share this answer
 
This is actually very easy.

The image datatype that stores an image in Sql Server is actually a byte stream. So just parse it and store the stream into a file using the same mime type.

This article might help you :
http://www.aspfree.com/c/a/ASP.NET/Retrieving-Images-from-a-Database--C---Part-II/


Cheers.
:rose:
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900