以字节为单位获取数据库存储中的图像 [英] Fetch image in database store in byte
本文介绍了以字节为单位获取数据库存储中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨朋友
i在数据库中以字节存储图像,现在问题是如何以字节格式获取和显示图像
谢谢
hi friends
i have store image in byte in database and now problem is how to fetch and display image in byte format
thanks
推荐答案
你必须使用文件流将字节数组转换为文件
You have to use file stream to convert byte array to file
//-------------------------------------------------------
byte[] yResult ; // retrive byte array from database and store in this
string strFileName ; // file name
//-------------------------------------------------------
if (yResult.Length > 0)
{
FileStream fs = File.Create(System.IO.Path.GetTempPath() + "\\" + strFileName, yResult.Length, FileOptions.None);
fs.Write(yResult, 0, yResult.Length);
fs.Close();
fs = null;
ProcessStartInfo pf = new ProcessStartInfo(System.IO.Path.GetTempPath() + "\\" + strFileName);
Process.Start(pf);
//-------------------------------------------------------
}
这篇关于以字节为单位获取数据库存储中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文