下面是本人实现的代码,也是通过网络查找到到的答案,所以做好来共享下:
DAOBean daobean = new DAOBean();//数据库访问类
string sql = "select PIC from TZ_PHOTO ";//读取大字段文件,如 bolg,long raw ,clog
byte[] filebyte = daobean.getBigByteDBRecord(sql);//转成字节数组
//数据库中大字段文件下载文件,基本原理为,读取相应的大字段列,转换为字节数组,在对字节数组 生成文件,或者进行下载
if (filebyte!=null)
{
Stream s = new MemoryStream(filebyte);//内存中 数据流,也可以直接通过
// FileInfo DownloadFile = new FileInfo(FilePath); //一样可以直接读取服务器上的文件,得到字节流
Response.Clear();
Response.ClearHeaders();
Response.Buffer = false;
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("ArcEngine+最短路径分析(C#源码).doc", System.Text.Encoding.UTF8));
Response.AppendHeader("Content-Length", filebyte.Length.ToString());
// Response.WriteFile(DownloadFile.FullName);//服务器文件
Response.BinaryWrite(filebyte); //二进制文件
Response.Flush();
Response.End();
}