//根據文件名(完全路徑)
public byte[] SetImageToByteArray(string fileName)
{ FileStream fs = new FileStream(fileName
int streamLength = (int)fs
fs
fs
return image; }
//另外
public byte[]
SetImageToByteArray(FileUpload FileUpload
{ Stream stream = FileUpload
byte[] photo = new byte[FileUpload
stream
stream
return photo;
}
//要使用SqlDataReader要加載using System
//將數據庫中的Image類型轉換成byte[] public byte[] SetImage(SqlDataReader reader)
{ return (byte[])reader[
//將byte[]轉換成Image圖像類型 //加載以下命名空間using System
using System
{ Image image; MemoryStream mymemorystream = new MemoryStream(mybyte
image = Image
return image;
}
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26884.html