.net 实现文件下载2
.net 實現文件下載 收藏
/// <summary>
???? /// 文件下載
???? /// </summary>
???? /// <param name="savename">文件名</param>
???? /// <param name="FullFileName">文件全名</param>
???? /// <param name="Response">Response</param>
?public static void savefile(string savename,string FullFileName,System.Web.HttpResponse Response)
???? {
???????? try
???????? {
???????????
???????????? FileInfo DownloadFile = new FileInfo(FullFileName);
???????????? if (DownloadFile.Exists)
???????????? {
???????????????? Response.Clear();
???????????????? Response.ClearHeaders();
???????????????? Response.Buffer = false;
???????????????? Response.ContentType = "application/octet-stream";
???????????????? Response.AppendHeader("Content-Disposition", "attachment;filename="+ System.Web.HttpUtility.UrlEncode(savename,System.Text.Encoding.UTF8));
????????????????
???????????????? Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
???????????????? Response.WriteFile(DownloadFile.FullName);
???????????????? Response.Flush();
???????????????? Response.End();
???????????? }
???????????? else
???????????? {
???????????????? //文件不存在
???????????? }
???????? }
???????? catch
???????? {
???????????? //文件不存在
???????? }
???? }
本文來自CSDN博客,轉載請標明出處:http://blog.csdn.net/chenjianyong94/archive/2009/05/06/4155379.aspx
轉載于:https://www.cnblogs.com/baohaiqi/archive/2010/09/07/1820216.html
總結
以上是生活随笔為你收集整理的.net 实现文件下载2的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: (转)使用互斥锁
- 下一篇: 我的Android学习之旅--1环境配置