如何从服务器当文件到本地并弹出下载提示框? 页面上点击 “下载” 按钮 弹出一个信息提示框 (很常见的那种) 问你是要打开 保存 还是取消从服务器当一个excel文件到本地。请问怎么做? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public static void DownloadFile(string physicalFilePath) { FileStream stream=null; stream = new FileStream(physicalFilePath, FileMode.Open, FileAccess.Read, FileShare.Read); int bufSize = (int)stream.Length; byte[] buf = new byte[bufSize]; int bytesRead = stream.Read(buf, 0, bufSize); HttpContext.Current.Response.ContentType = "application/octet-stream"; HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename="+System.IO.Path.GetFileName(physicalFilePath)); HttpContext.Current.Response.OutputStream.Write(buf, 0, bytesRead); HttpContext.Current.Response.End(); } 求助C#中的控件显示——要求显示为如下表格的形式 在Treeview控件中操作checkbox 这是怎么会是 image 控件图片关于导出WORD文档,无法显示的问题 连接的是SQL server2005 读取最新的20条数据 怎么在后台定时运行读文件程序 关于用户自定义控件的问题 下面的sql怎么定义变量? 急!这是什么错误!!!给出答案着马上加分 简直莫名其妙,非常困惑,毫无办法。页面居然没有规律的出错! 那些web控件真是不好用,还是自己来写吧 麻烦大家给给建议^_^
{
FileStream stream=null;
stream = new FileStream(physicalFilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
int bufSize = (int)stream.Length;
byte[] buf = new byte[bufSize]; int bytesRead = stream.Read(buf, 0, bufSize);
HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename="+System.IO.Path.GetFileName(physicalFilePath));
HttpContext.Current.Response.OutputStream.Write(buf, 0, bytesRead);
HttpContext.Current.Response.End();
}