日期:2014-05-16 浏览次数:20787 次
public static byte[] imagetobyte() //将图片转换为byte[]
{
if (Imagepath != "") //检查图片路径是否为空
{
FileStream filestream = new FileStream(Imagepath, FileMode.Open);
BinaryReader binnaryreader = new BinaryReader(filestream);
byte[] imagebinnary = binnaryreader.ReadBytes((int)filestream.Length);
binnaryreader.Close();
filestream.Close();
return imagebinnary;
}
else
{
return DBNull.Value;
}
}