string sql = "select * from table where xx='xxx'";
DataTable ta = new DataTable();
ta = DBHelper.getDataTable(sql);
byte[] bytes = (byte[])ta.Rows[0]["列"]; //把查詢的base64檔案轉陣列
/呼叫方法
Bytes2File(bytes, "給一個下載在哪里的路徑");如E:\\測驗\\xxxx.pdf/ 后綴要加上
public static void Bytes2File(byte[] buff, string savepath)
{
if (System.IO.File.Exists(savepath))
{
System.IO.File.Delete(savepath);
}
FileStream fs = new FileStream(savepath, FileMode.CreateNew);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(buff, 0, buff.Length);
bw.Close();
fs.Close();
}
uj5u.com熱心網友回復:
System.IO.File.WriteAllBytes()
一句話就搞定了.
uj5u.com熱心網友回復:
用了報錯,后面WriteAllBytes報錯轉載請註明出處,本文鏈接:https://www.uj5u.com/net/64908.html
標籤:ASP.NET
