網上關於ASP
存儲圖片類型數據有以下幾種方式
byte[] fileData = this
代碼
public byte[] returnbyte(string strpath)
{
// 以二進制方式讀文件
FileStream fsMyfile = new FileStream(strpath
// 創建一個二進制數據流讀入器
BinaryReader brMyfile = new BinaryReader(fsMyfile);
// 把文件指針重新定位到文件的開始
brMyfile
byte[] bytes = brMyfile
// 關閉以上new的各個對象
brMyfile
return bytes;
}
public static byte[] Getbyte(Image img)
{
MemoryStream stream = new MemoryStream();
img
byte[] mydata = new byte[stream
mydata = stream
stream
return mydata;
}
讀取image類型的數據並顯示在網頁上的方式如下
private System
{
string sql = "select IMGDATA from t_img where imgID=
string strconn = System
OracleConnection oraConn = new OracleConnection(strconn);
OracleCommand oraComm = new OracleCommand(sql
oraConn
byte[] fileData = (byte[])oraComm
oraConn
System
System
return img;
}
頁面ImageShow
protected void Page_Load(object sender
{
byte[] b_logoImg = (byte[])dt_channelImg
if (b_logoImg
{
System
MemoryStream ms = new MemoryStream(b_logoImg);
Response
Response
Response
Response
}
}
圖片路徑寫成為
From:http://tw.wingwit.com/Article/program/net/201311/14264.html