首页 新闻 论坛 群组 Blog 文档 下载 读书 Tag 网摘 搜索 .NET Java 游戏 视频 人才 外包 数据库 第二书店 程序员

做了个图书网站-----想实现提供下载功能。????怎么办呢

zifeng759收录,时间:2008-1-11 16:57:57 | 相关网摘我也收藏

public void FileDownload(string FullFileName)
{
     System.Web.HttpContext context = System.Web.HttpContext.Current;
FileInfo DownloadFile = new FileInfo(FullFileName);
context.Response.Clear();
context.Response.ClearHeaders();
context.Response.Buffer = false;
context.Response.ContentType = "application/octet-stream ";
//Response.ContentType = "application/ms-excel ";
context.Response.AppendHeader( "Content-Disposition ", "attachment;filename= " HttpUtility.UrlEncode(DownloadFile.FullName, System.Text.Encoding.UTF8));
context.Response.AppendHeader( "Content-Length ", DownloadFile.Length.ToString());
context.Response.WriteFile(DownloadFile.FullName);

context.Response.Flush();
context.Response.End();
}




相关网摘:



网站简介广告服务网站地图帮助联系方式诚聘英才English 问题报告
北京创新乐知广告有限公司 版权所有 京 ICP 证 070598 号
Copyright © 2000-2008, CSDN.NET, All Rights Reserved