idrisgani
March 24th, 2009, 11:02 AM
Hi , i want to save the image from the database to an physical location like C:\one.JPG. the datatype of the column in the table is Image. i tried with working with MemoryStream. but i am not suceed. i am getting "Parameter not valid" when converting the stream to image "Image.fromStream(ms,true)".
DataView dv = new DataView(ds.Tables[0], null, null, DataViewRowState.CurrentRows);
byte[] imageData =(Bytes) dv[0][3];
Image newImage;
//Read image data into a memory stream
using (MemoryStream ms = new MemoryStream(imageData, 0, imageData.Length))
{
ms.Write(imageData, 0, imageData.Length);
//Set image variable value using memory stream.
newImage = Image.FromStream(ms, true);
}
DataView dv = new DataView(ds.Tables[0], null, null, DataViewRowState.CurrentRows);
byte[] imageData =(Bytes) dv[0][3];
Image newImage;
//Read image data into a memory stream
using (MemoryStream ms = new MemoryStream(imageData, 0, imageData.Length))
{
ms.Write(imageData, 0, imageData.Length);
//Set image variable value using memory stream.
newImage = Image.FromStream(ms, true);
}