首页 新闻 会员 周边

C# 怎么打开图片

0
[待解决问题]
 private void button1_Click(object sender, EventArgs e)
        {
                        SqlConnection Conn = new SqlConnection("server=192.168.0.231;database=PatPD1;uid=sa;password=nbm");
            SqlDataAdapter da = new SqlDataAdapter("select * from sureboy where picture is not null", Conn);
            DataTable dt = new DataTable();
            da.Fill(dt);
            byte[] bytes =(byte[])dt.Rows[0][7];
            MemoryStream ms = new MemoryStream(bytes);
            Image image = Image.FromStream(ms);
            image.Save(@"C:\Users\s-2188\Desktop\123.jpg");
            System.Diagnostics.Process.Start(@"C:\Users\s-2188\Desktop\123.jpg");
            File.Delete(@"C:\Users\s-2188\Desktop\123.jpg");
        }

像我这样,要先保存,打开,再删除,太麻烦了,有没有能直接打开image的方法

Sureboy的主页 Sureboy | 菜鸟二级 | 园豆:212
提问于:2012-10-08 14:06
< >
分享
所有回答(2)
0

如果是直接将二进制转图片,可以参考  http://blog.csdn.net/adensky/article/details/6302999#

xyq_雨晴 | 园豆:159 (初学一级) | 2012-10-08 14:11
0

数据库里为什么不直接保存图片的名称和扩展名,其他路径写在配置文件中呢?

答应不爱你 | 园豆:3 (初学一级) | 2012-10-08 16:56
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册