怎么在网页中加入文件下载 C# 数据库中有下载文件名称 怎么在网页中加入文件下载 代码怎么写啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string fileName = ""; string filePath = Server.MapPath("");//路径 FileInfo fileInfo = new FileInfo(filePath); Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName); Response.AddHeader("Content-Length", fileInfo.Length.ToString()); Response.AddHeader("Content-Transfer-Encoding", "binary"); Response.ContentType = "application/octet-stream"; Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312"); Response.WriteFile(fileInfo.FullName); Response.Flush(); Response.End(); 简单的,用<a>标签也行,直接链接到文件 wcf中wsDualHttpBinding的问题 请问在C#中,如何实现将输入的字符串按照相反的顺序输出? 知道不知道,都来瞧一瞧 如何结束整个程序的执行问题? c#连接到ftp的问题 求outlookbar源码 在网站嵌入google地图,在ie6和遨游浏览器不能访问,在其他浏览器能看到!急! C#画线问题 奇怪的问题! WPF 怎么通过 button的Click事件传递参数到后台处理 c# 如何通过xml进行交互? C#交互式的提示框!!!
string filePath = Server.MapPath("");//路径
FileInfo fileInfo = new FileInfo(filePath);
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);
Response.AddHeader("Content-Length", fileInfo.Length.ToString());
Response.AddHeader("Content-Transfer-Encoding", "binary");
Response.ContentType = "application/octet-stream";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
Response.WriteFile(fileInfo.FullName);
Response.Flush();
Response.End();