您的位置:首页 > 其它

程序实现下载文件或者打开文件

2010-04-03 12:21 239 查看
FileInfo DownloadFile = new FileInfo("c:\\a.doc"); // 下面到就是读取文件,通过数据流的方式下载了。 Response.Clear(); Response.ClearHeaders(); Response.Buffer = false; Response.ContentType = "application/octet-stream"; Response.AppendHeader("Content-Disposition", "inline;filename=" + HttpUtility.UrlEncode("c:\\a.doc", System.Text.Encoding.UTF8)); Response.AppendHeader("Content-Length", DownloadFile.Length.ToString()); Response.WriteFile(DownloadFile.FullName); Response.Flush(); Response.End(); Content-Disposition:inline是直接打开,attachment是保存。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐