如何把一张图片转换成Stream
如何把一张图片专程System.io.Stream?
------解决方案-------------------- FileStream fileStream = new FileStream("图片路径", FileMode.Open);
Stream stream = fileStream as Stream;
------解决方案-------------------- Stream stream = null;
System.Drawing.Image.FromFile("图片路径").Save(stream, ImageFormat.Jpeg);
------解决方案--------------------可将图片转成二进制,然后存储到数据库中
------解决方案--------------------给你方法:
System.IO.FileStream fs = new System.IO.FileStream(Server.MapPath("Images图片.jpg", System.IO.FileMode.Open);
byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
fs.Close();
------解决方案--------------------不好意思少了个括号:
System.IO.FileStream fs = new System.IO.FileStream(Server.MapPath("Images图片.jpg"), System.IO.FileMode.Open);
byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
fs.Close();
------解决方案--------------------验证6楼正解,winform的