日期:2014-05-17 浏览次数:20580 次
/// <summary> /// 从数据库读取相应图片 /// </summary> /// <param name="name">图片名称</param> /// <returns>返回该图片</returns> public static Image GetImage(string name) { SqlConnection con = new SqlConnection(SqlConString); SqlCommand cmd = con.CreateCommand(); SqlParameter pname = new SqlParameter("@name", name); cmd.Parameters.Add(pname); cmd.CommandText = "select image from MyTable where name=@name"; con.Open(); byte[] MyData = (byte[])cmd.ExecuteScalar(); MemoryStream ms = new MemoryStream(MyData, 0, MyData.Length); ms.Seek(0, SeekOrigin.Begin); Image image = Image.FromStream(ms); con.Close(); return image; }
------解决方案--------------------
files[0].ContentLength这个是内容吧。
byte[] data=system.io.file.read();
------解决方案--------------------