最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp.net实现服务器文件下载到本地的方法
时间:2017-03-16 编辑:简简单单 来源:一聚教程网
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); |
-
上一个: c# 中文转拼音without CJK
相关文章
- ASP.NET调用jarsigner.exe失败:系统找不到指定的文件 12-05
- ASP.NET实现文件断点续传代码 06-06
- asp.net中Silverlight文件操作 02-01
- asp.net Global.asax文件与HttpApplication详解 05-10
- asp.net实现 文件断点续传的功能 01-25
- asp.net 检查文件夹和文件是否存在 01-21