最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp.net实现服务器文件下载到本地的方法
时间:2022-06-25 06:56:13 编辑:袖梨 来源:一聚教程网
1、说明
通过文件下载框实现将服务器上的文件下载到本地指定位置。这里需要指定服务器文件路径
| 代码如下 | 复制代码 |
//服务器文件路径 stringstrFilePath = Server.MapPath("~") +"/excel/20170206104654.xlsx"; FileInfo fileInfo =newFileInfo(strFilePath); Response.Clear(); Response.AddHeader("content-disposition","attachment;filename="+ Server.UrlEncode(fileInfo.Name.ToString())); Response.AddHeader("content-length", fileInfo.Length.ToString()); Response.ContentType ="application/octet-stream"; Response.ContentEncoding = System.Text.Encoding.Default; Response.WriteFile(strFilePath); | |
相关文章
- 我的世界刷怪塔怎么建造 06-28
- 荣耀90gt怎么设置返回键图标 06-28
- 暑假去神农架原始丛林旅游如何有效防蚊虫 06-28
- 明日方舟终末地折金票详解 明日方舟终末地限定兑换道具全解析 06-28
- 明日方舟终末地衍质源石作用详解 明日方舟终末地衍质源石获取与使用方法 06-28
- 明日方舟终末地下载大小及最低配置要求详解 明日方舟终末地安装包体积与设备兼容性指南 06-28

