将一个图片文件转换为字节流存入数据库

 1//将一个图片文件转换为字节流存入数据库
 2string pictureFilePath = "";
 3Byte[] bt;
 4pictureFilePath = @"C:\temp.bmp";
 5FileStream fs = new FileStream(pictureFilePath,FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
 6
 7bt = new byte[Int32.Parse(fs.Length.ToString())];
 8
 9fs.Read(bt,0,Int32.Parse(fs.Length.ToString()));
10
11
12
13sqlComm.Parameters.Add("@CMPicture",bt);
14
15
原文地址:https://www.cnblogs.com/telephoner/p/188096.html