不多说了,把代码放上来
图片的1.gif你可以根据你的要求,另存为,可以采用时间做为名字来处理
- SqlConnection conn = new SqlConnection("server=.;uid=sa;pwd=123;database=am89resource");
- conn.Open();
- SqlCommand cmd = new SqlCommand("",conn);
- cmd.CommandText = "select * from picture where id='0331010009'";
- SqlDataReader dr = cmd.ExecuteReader();
- if (dr.Read())
- {
- //byte[] file = (Byte[])dr["img"];
- //BinaryWriter bw = new BinaryWriter(fs);
- //bw.Write(file,0,file.Length);
- //Response.BinaryWrite(file);
- byte[] bytes = (byte[])dr["img"];
- FileStream fs = new FileStream(Server.MapPath("//img//1.gif"), FileMode.Create, FileAccess.Write);
- fs.Write(bytes, 0, bytes.Length);
- fs.Flush();
- fs.Close();
- }
- conn.Close();