二进制流输出各种类型文件 二进制流输出各种类型文件数据库保存为二进制流,也保存有文件名和后缀名,怎么在web页面输出各种类型的文件。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Refer:http://www.cnblogs.com/insus/articles/2012733.html yte[] filec = (byte[])(ds.Tables[0].Rows[0]["FContent"]); Response.Clear(); string FileName = ds.Tables[0].Rows[0]["FName"].ToString(); string FullName = ds.Tables[0].Rows[0]["FullName"].ToString(); //类型 string imageType = System.IO.Path.GetExtension(FullName).ToLower(); if (imageType == ".jpg") { ResponseEnd(filec, FullName); } if (imageType == ".doc") { ContentType = "application/msword"; Response.ContentType = ContentType; Response.ContentEncoding = System.Text.Encoding.Unicode; Response.AddHeader("Content-Disposition ", "attachment;filename=" + FullName); Response.Charset = "GB2312 "; Response.OutputStream.Write(filec, 0, filec.Length); Response.End(); } if (imageType == ".xls") { ContentType = "application/vnd.ms-excel"; Response.ContentType = ContentType; Response.ContentEncoding = System.Text.Encoding.Unicode; Response.AddHeader("Content-Disposition ", "attachment;filename=" + FullName); Response.Charset = "GB2312 "; Response.OutputStream.Write(filec, 0, filec.Length); Response.End(); } if (imageType == ".pdf") { ContentType = "application/pdf"; Response.ContentType = ContentType; Response.ContentEncoding = System.Text.Encoding.Unicode; Response.AddHeader("Content-Disposition ", "attachment;filename=" + FullName); Response.Charset = "GB2312 "; Response.OutputStream.Write(filec, 0, filec.Length); Response.End(); } if (imageType == ".pdf")或 if (imageType == ".txt")时不显示 (GUID)uniqueidentifier插入后如何返回插入的值? 动态改变checkbox的选项框个数???? 如何让 两个UpdatePanel 不同时刷新。。。 vs2008 oracle数据库 大家帮我看看 repeater前台页面调用后台定义的函数为什么不行呢? asp的VBScript语句转化为C# 如何 让datagrid 没有 caption项,即使没有文字,我发现caption也占位了 急!visual studio 2012 无法启动程序调试 發送email問題 跪求高手解决.NET问题 关于生命周期的问题
http://www.cnblogs.com/insus/articles/2012733.html
Response.Clear();
string FileName = ds.Tables[0].Rows[0]["FName"].ToString();
string FullName = ds.Tables[0].Rows[0]["FullName"].ToString();
//类型
string imageType = System.IO.Path.GetExtension(FullName).ToLower();
if (imageType == ".jpg")
{
ResponseEnd(filec, FullName);
}
if (imageType == ".doc")
{
ContentType = "application/msword";
Response.ContentType = ContentType;
Response.ContentEncoding = System.Text.Encoding.Unicode;
Response.AddHeader("Content-Disposition ", "attachment;filename=" + FullName);
Response.Charset = "GB2312 ";
Response.OutputStream.Write(filec, 0, filec.Length);
Response.End();
}
if (imageType == ".xls")
{
ContentType = "application/vnd.ms-excel";
Response.ContentType = ContentType;
Response.ContentEncoding = System.Text.Encoding.Unicode;
Response.AddHeader("Content-Disposition ", "attachment;filename=" + FullName);
Response.Charset = "GB2312 ";
Response.OutputStream.Write(filec, 0, filec.Length);
Response.End();
}
if (imageType == ".pdf")
{
ContentType = "application/pdf";
Response.ContentType = ContentType;
Response.ContentEncoding = System.Text.Encoding.Unicode;
Response.AddHeader("Content-Disposition ", "attachment;filename=" + FullName);
Response.Charset = "GB2312 ";
Response.OutputStream.Write(filec, 0, filec.Length);
Response.End();
}
if (imageType == ".pdf")
或 if (imageType == ".txt")时不显示