我想用这种方式来获取图像,但它不会
问题描述:
我不能从数据库中检索图像我想用这种方式来获取图像,但它不会
byte[] image = (byte[])(reader["Can_Pic"]);
if (image == null)
{
Picture.Image = null;
}
else
{
Memory Stream stream = new Memory Stream(image);
Picture.Image = System.Drawing.Image.From Stream(stream);
}
答
您的代码应该是这样的:-)
Byte[] image=(Byte[])(reader["Can_Pic"]);
if (image.Length == 0)
{
Picture.Image = null;
}
else
{
MemoryStream stream = new MemoryStream();
stream.Write(image, 0, image.Length);
Picture.Image = new Bitmap(stream);
}
什么之间的''space'字符从'和'Stream'?在你提供的代码的最后一行 – jfun 2015-02-08 06:11:25
当我问问题。它变成了错误。所以我添加它的空间,以便我可以发布我的代码 – 2015-02-10 15:08:45