I have a data table called dtchild
and it contains a column named FILE_CONTENT
. In my data table, FILE_CONTENT
data is stored as a byte[]
array.
How to retrieve FILE_CONTENT
data from the data table and convert it into an image?
I have a data table called dtchild
and it contains a column named FILE_CONTENT
. In my data table, FILE_CONTENT
data is stored as a byte[]
array.
How to retrieve FILE_CONTENT
data from the data table and convert it into an image?
// bytes is the byte[]
array of your file content :
using(MemoryStream ms = new MemoryStream(bytes))
{
var Image = Image.FromStream(ms);
}
Considering you want to show image in asp.net web forms
Try this code , on aspx page :
<img id='yourID' runat='server'/>
On CS page
byte[] Binary = (byte[])(dt.Rows[0]["Your column"]);
string base64string= Convert.ToBase64String(Binary, 0, Binary.Length);
yourID.Src = "data:image/jpg;base64," + base64String;
byte[] imgData = (byte[])dt.Rows[0]["Photo"];
MemoryStream ms = new MemoryStream(imgData);
Image img = Image.FromStream(ms);
pictureBox1.Image = img;