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的方法
数据库里为什么不直接保存图片的名称和扩展名,其他路径写在配置文件中呢?