0

我在将图像保存在数据库中时遇到此错误,请提前与我分享一些解决方案

string objImage = Path.GetFullPath(objPB.Picture);

FileStream fs = new FileStream(objImage, FileMode.Open, FileAccess.Read);
Image img = Image.FromStream(fs);
fs.Close();

byte[] objbyte = imageToByteArray(img);


public static byte[] imageToByteArray(System.Drawing.Image imageIn)    
{    
   MemoryStream ms = new MemoryStream();
   imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
   return ms.ToArray();    
}
4

0 回答 0