asp.net文件下载
2015-05-29 16:59
716 查看
xmlDoc.Save(xmlSavePath); FileStream fileStream = new FileStream(xmlSavePath, FileMode.Open); long fileSize = fileStream.Length; byte[] fileBuffer = new byte[fileSize]; fileStream.Read(fileBuffer, 0, (int)fileSize); //如果不写fileStream.Close()语句,用户在下载过程中选择取消,将不能再次下载 fileStream.Close(); Context.Response.ContentType = "application/octet-stream"; Context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(DateTime.Now.ToString("yyyyMMddhhmmss") + ".xml", Encoding.UTF8)); Context.Response.AddHeader("Content-Length", fileSize.ToString()); Context.Response.BinaryWrite(fileBuffer); Context.Response.End(); Context.Response.Close();
相关文章推荐
- ASP.NET Ajax client-side framework failed to load OR ‘Sys’ is undefined(ASP.NET Ajax 客户端框架未能加载)
- jasperserver 创建带查询的报表
- 资源链接
- Web 开发中很实用的10个效果【源码下载】
- 好用的ASP.NET 分页类 简单好用 支持 AJAX 自定义文字
- ASP.NET获取服务器信息命令集合
- RaspberrIPCam – Full HD IP Camera based on Raspberry Pi
- Building Qt 5 on Raspberry Pi(为树莓派交叉编译Qt5)
- gstremer 1.2 compile and install on raspberry pi(在树莓派上编译gstreamer1.2,gstreamer1.0及以上版本的编译可参照此教程)
- 将树莓派Raspberry Pi设置为无线路由器(WiFi热点AP,RTL8188CUS芯片)
- SharePoint 2013 地址栏_layouts/15/start.aspx#
- ASP.NET让FileUpload控件支持浏览自动上传功能的解决方法
- ASP.NET获取客户端、服务器端的信息
- Asp.Net 之 使用Form认证实现用户登录 (LoginView的使用)
- Spring 之AOP AspectJ切入点语法详解(最全了,不需要再去其他地找了)
- asp access 80004005 错误
- Use cases about the V4L2 driver for the Dual Raspberry Pi Camera Module
- 学习ASP.NET MVC5框架揭秘笔记-ASP.NET路由(十二)
- How to install or upgrade UV4L on Raspbian (for the Raspberry Pi)
- AspNet MVC4 教学-20:Asp.Net MVC4 Routing技术快速应用Demo