自动识别下载文件的类型问题 是不适应该改这个Response.ContentType = "application/octet-stream"; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 浏览器是靠文件的扩展名来识别文件类型的;即这句Response.AddHeader("Content-Disposition", "attachment; filename=" + filename );中filename中的文件扩展名。 在大家的帮助下做出来了,分享一下主要是下载的if (dr.Read()) { string km = dr["附件类型"].ToString().Trim(); string name = "TEXT" +"."+ km; byte[] barrImage = (byte[])dr["附件"]; System.IO.MemoryStream ms = new System.IO.MemoryStream(barrImage); Response.ClearContent(); Response.ContentEncoding = System.Text.Encoding.UTF8; // 添加 信息, "文件下 /另存 " 框指定默 文件名 Response.AddHeader("Content-Disposition", "attachment; filename=" +name ); // 添加 信息,指定文件大小, 器能 示下 度 Response.AddHeader("Content-Length", barrImage.Length.ToString()); Response.ContentType = "application/octet-stream"; Response.BinaryWrite(ms.ToArray()); Response.End(); } dr.Close(); strConn.Close(); 求事件的例子 EF中继承的问题,高手帮忙。 窗体侧边栏怎么做? 第四段的C#代码 既然大家都喜欢这么出题竞赛,那我也凑个热闹,写一个超大整数类。 在ASP.net中怎么样才能实现图片的重绘? 求助:关于web上的DATAGRID的更新问题 winform等待窗体 C#winform toolTip控件显示时间太短 向acewang表示歉意,请斑竹保留 如何实现vs2005的多文档标签? 简单问题
Response.AddHeader("Content-Disposition", "attachment; filename=" + filename );中filename中的文件扩展名。
主要是下载的if (dr.Read())
{
string km = dr["附件类型"].ToString().Trim();
string name = "TEXT" +"."+ km;
byte[] barrImage = (byte[])dr["附件"];
System.IO.MemoryStream ms = new System.IO.MemoryStream(barrImage);
Response.ClearContent();
Response.ContentEncoding = System.Text.Encoding.UTF8;
// 添加 信息, "文件下 /另存 " 框指定默 文件名
Response.AddHeader("Content-Disposition", "attachment; filename=" +name );
// 添加 信息,指定文件大小, 器能 示下 度
Response.AddHeader("Content-Length", barrImage.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(ms.ToArray());
Response.End();
}
dr.Close();
strConn.Close();