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

 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

posted on 2005-07-07 20:07  马维拉的真实之眼  阅读(2434)  评论(0编辑  收藏  举报

导航