1
//将一个图片文件转换为字节流存入数据库
2
string pictureFilePath = "";
3
Byte[] bt;
4
pictureFilePath = @"C:\temp.bmp";
5
FileStream fs = new FileStream(pictureFilePath,FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
6
7
bt = new byte[Int32.Parse(fs.Length.ToString())];
8
9
fs.Read(bt,0,Int32.Parse(fs.Length.ToString()));
10
11

12
13
sqlComm.Parameters.Add("@CMPicture",bt);
14
15

//将一个图片文件转换为字节流存入数据库2
string pictureFilePath = "";3
Byte[] bt;4
pictureFilePath = @"C:\temp.bmp";5
FileStream fs = new FileStream(pictureFilePath,FileMode.Open, FileAccess.Read, FileShare.ReadWrite);6

7
bt = new byte[Int32.Parse(fs.Length.ToString())];8

9
fs.Read(bt,0,Int32.Parse(fs.Length.ToString()));10

11


12

13
sqlComm.Parameters.Add("@CMPicture",bt);14

15

