C# 如何将Image类型转换为 string 类型 我sql2000数据库里的一个字段是Image类型 都是将图片以字节流的形式存进去的 现在想取出来 并保存在某个文件夹下(例如 C:\) 请问该如何实现 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 那也不应该转成string啊你是想从数据库提取出数据,生成图片,放某个文件夹里吗? 用FileStream来操作,将字节流写入文件应该就可以啦。 Image类型的字段,用byte数组来存储 例如:FileStream fs = File.OpenRead("E:\\test.jpg");byte[] imageb = new byte[fs.Length];fs.Read(imageb, 0, imageb.Length);我将 E:\\test.jpg 这个文件以字节流的形式赋值给 imageb然后再保存到数据库的Image类型的字段下但是怎么取出来保存在另一个文件夹下啊..?还有就是取出来后..名称是什么..? //我当你会从数据库中取出数据啦。 DataRow dr=dataSet.Tables[0].Rows[0];//仅举某一条记录作为例子。 byte[] photo; if(dr["Photo"]!=DBNull.Value) { photo=(byte[])dr["Photo"]; MemoryStream stream=new MemoryStream(photo,0,photo.Length,true); Image img=Image.FromStream(stream); img.Save(@"C:\1.jpg"); } DataRow dr = dataSet.Tables[0].Rows[0];byte[] photo ;if (dr["photo"]!= DBNull.Value){photo = (byte[])dr["photo"];MemoryStream stream = new MemoryStream (photo ,0 ,photo.Length,true);Image img = Image.FormStream(stream);img.Save(@"c:\1.jpg");}! 求C#动态菜单~~! c# window service 绝对路径 如何用gridview中模板列中的按钮向数据库中添加数据? 怎样用WIS打包时讲。NET框架装进去? 对委托和事件的一些地方不太理解 用vs2005的lonig控件登陆后,如何保护当前页面?如果以登陆的用户名为的权限判断代码怎么写? .Net名字空间纵览------->>>>>请你指出你常用哪个名字空间! 为何属性也有方法 Datagrid高手帮忙,谁先解决我给谁分 请问类如何返回数组? C# 中如何动态创建方法中的参数以及函数中的变量。 有没有什么方法,初始化一个DATAGRID时,就触发下它的排序事件?
你是想从数据库提取出数据,生成图片,放某个文件夹里吗?
FileStream fs = File.OpenRead("E:\\test.jpg");
byte[] imageb = new byte[fs.Length];
fs.Read(imageb, 0, imageb.Length);
我将 E:\\test.jpg 这个文件以字节流的形式赋值给 imageb
然后再保存到数据库的Image类型的字段下但是怎么取出来保存在另一个文件夹下啊..?
还有就是取出来后..名称是什么..?
DataRow dr=dataSet.Tables[0].Rows[0];//仅举某一条记录作为例子。
byte[] photo;
if(dr["Photo"]!=DBNull.Value)
{
photo=(byte[])dr["Photo"];
MemoryStream stream=new MemoryStream(photo,0,photo.Length,true);
Image img=Image.FromStream(stream);
img.Save(@"C:\1.jpg");
}
byte[] photo ;
if (dr["photo"]!= DBNull.Value)
{
photo = (byte[])dr["photo"];
MemoryStream stream = new MemoryStream (photo ,0 ,photo.Length,true);
Image img = Image.FormStream(stream);
img.Save(@"c:\1.jpg");
}
!