如何在网页中显示 doc,xls,pdf,txt 等文件(文件数据都是以二进制形式保存到数据库的)? 如何在网页中显示 doc,xls,pdf,txt 等文件(文件数据都是以二进制形式保存到数据库的)?谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 从数据库取出来就是一个 byte[] 类型的数据,我数据库有一个字段可以识别文件是什么类型的,但不知该如何在网页中显示出来 把byte[]转换为string 再显示出来 怎么可能这样?BYTE网页就显示一个BYTE[] System_Data sd = new System_Data(); SqlDataReader myRead = sd.getSqlDataReader_For_Sql("select data from imagedata"); if (myRead.Read()) { Byte[] Buffer = (Byte[])myRead[0]; this.Response.Clear(); this.Response.ContentType = "application/msword"; this.Response.AddHeader("Content-Disposition", "inline; filename=" + "aaaa.doc"); this.Response.BinaryWrite(Buffer); this.Response.End(); } myRead.Close();图片和TXT可以用这个程序,但DOC,XLS是乱码 excel用application/vnd.ms-excelresponse.ContentType = "application/octet-stream";response.Charset = "UTF-8";response.ContentEncoding = System.Text.Encoding.UTF8;response.HeaderEncoding = System.Text.Encoding.UTF8; 猜数器 System.web.mail发邮件出现的错误。 C#中 Queue是连续内存吗? 求助解析指令字符串 VS2005和vs2008net FrameWork问题 在一个类中,有这样一个函数,它错在哪里? 怎么注册 QuartzTypeLib 请教关于导出数据库到Excel的程序在生成安装程序后,安装程序不能运行的问题!(各位高人帮忙啊!) 2005文档自动生成问题 C# N个数组相乘 还是关于datagridview里的checkbox列点击事件的严重的问题. 获取oracle查询结果问题
SqlDataReader myRead = sd.getSqlDataReader_For_Sql("select data from imagedata");
if (myRead.Read())
{
Byte[] Buffer = (Byte[])myRead[0];
this.Response.Clear();
this.Response.ContentType = "application/msword";
this.Response.AddHeader("Content-Disposition", "inline; filename=" + "aaaa.doc");
this.Response.BinaryWrite(Buffer);
this.Response.End();
}
myRead.Close();图片和TXT可以用这个程序,但DOC,XLS是乱码
response.ContentType = "application/octet-stream";
response.Charset = "UTF-8";
response.ContentEncoding = System.Text.Encoding.UTF8;
response.HeaderEncoding = System.Text.Encoding.UTF8;