Extract images from sql server

  • Thread starter Thread starter Filip De Backer
  • Start date Start date
F

Filip De Backer

Hi,

I've got a column in a table which contains images (bmp
and jpg, i guess sql server don't convent the jpg to
bmp??).

How can I extract these images from the table.
I've tried something with a MemoryStream, but I don't know
how to save it to a file because this stream is a byte
array and I can't check the file type and other stuff like
that.

Is there anybody with the same problem?

Thanks a lot

Filip
 
........................
Type type = Table.Rows[0]["bitmap"].GetType();
System.Byte[] buf = Table.Rows[0]["bitmap"] as Byte[];

SaveFileDialog saveFileDialog1 = new SaveFileDialog();
if(saveFileDialog1.ShowDialog() == DialogResult.OK)
{
FileStream fs = new FileStream(saveFileDialog1.FileName, FileMode.Create, FileAccess.Write);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(buf);
bw.Close();
fs.Close();
}

..................................
This code worked in my case.

Best regards,
Sergey Ivasenko.
 
Back
Top