我总结的写入和读出图片:
写入:System.IO.FileStream fs = new System.IO.FileStream (fileName,System.IO.FileMode.Open,System.IO.FileAccess.Read);
System.IO.BinaryReader br = new System.IO.BinaryReader(fs);
byte[] mybyte = new byte[(int)fs.Length];
br.Read(mybyte,0,mybyte.Length);
newdr["Photo"] = mybyte;
读出:
Byte[] Imbyte = new Byte[0];
Imbyte = (Byte[])(DB中的数据);
MemoryStream ms = new MemoryStream(Imbyte);
PicPhoto.Image= Image.FromStream(ms);
写入:System.IO.FileStream fs = new System.IO.FileStream (fileName,System.IO.FileMode.Open,System.IO.FileAccess.Read);
System.IO.BinaryReader br = new System.IO.BinaryReader(fs);
byte[] mybyte = new byte[(int)fs.Length];
br.Read(mybyte,0,mybyte.Length);
newdr["Photo"] = mybyte;
读出:
Byte[] Imbyte = new Byte[0];
Imbyte = (Byte[])(DB中的数据);
MemoryStream ms = new MemoryStream(Imbyte);
PicPhoto.Image= Image.FromStream(ms);