asp.net 下载文件
?????? //源文件名稱
?????? //提供下載的文件,不編碼的話文件名會(huì)亂碼????
??????? //private string fileName = HttpContext.Current.Server.UrlEncode("規(guī)范.rar");???
????? ? string fileName = @"D:\我的文檔\Visual Studio 2010\WebSites\WebSite14\a00.zip";???
??????? FileInfo info = new FileInfo(fileName);
??????? long fileSize = info.Length;
??????? Response.Clear();
??????? Response.ContentType = "application/octet-stream";
??????? Response.AddHeader("Content-Disposition", "attachement;filename=" + "您希望顯示的文件名稱.rar"); //這里的文件名稱也應(yīng)該編碼
??????? //指定文件大小???
??????? Response.AddHeader("Content-Length", fileSize.ToString());
??????? Response.WriteFile(fileName, 0, fileSize);
??????? Response.Flush();
??????? Response.Close();
?
請參考:
http://zhidao.baidu.com/question/171876794.html
轉(zhuǎn)載于:https://www.cnblogs.com/zhwl/archive/2011/08/25/2153537.html
總結(jié)
以上是生活随笔為你收集整理的asp.net 下载文件的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 中国车牌特征
- 下一篇: c#通过app.manifest使程序