CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
英特尔®游戏设计大赛100美元现金周周送 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  .NET技术 >  ASP.NET

请教关于文件下载的问题

楼主michael2004(最后第一次)2003-11-03 12:42:25 在 .NET技术 / ASP.NET 提问

如果在页面点击文件下载时,如pdf文件,但客户端本机没有安装acrobat   reader,弹出提示保存对话框,我想请问如果保存或取消后,可以将该页面刷新吗?谢谢!! 问题点数:0、回复次数:4Top

1 楼gasover(无尽)回复于 2003-11-03 13:28:34 得分 0

可以,不要用Response.End()   来结束,用Response.Flush()   就不会导致页面关闭。然后后面可以继续的操作。下次问问题记得要给分。Top

2 楼michael2004(最后第一次)回复于 2003-11-03 14:38:22 得分 0

很感谢您的帮助和提醒,可是分数不大够,我想问对新手而言,如何取分呢,我.net方面是刚入门的,没什么经验,根本就不能帮上别人什么忙,所以不能取分。还望各位大哥大姐谅解!  
   
  另外,我在code中没有写上response.end(),这是什么意思呢,而flush,是要设成true吗,望再指点一下吧!!谢了!Top

3 楼gasover(无尽)回复于 2003-11-04 11:54:39 得分 0

记得每天登陆这个论坛一次,有10分领,你问问题的时候,也起个10分为好,因为如果您一分都不给的话,大家会认为您故意不遵守论坛的规矩的。所以不会给您回复。   :)  
   
        我把我得下载代码给您参考一下吧:  
  string   path   =   Server.MapPath(Request.Params["File"]);  
  System.IO.FileInfo   file   =   new   System.IO.FileInfo(path);  
   
  //   clear   the   current   output   content   from   the   buffer  
  Response.Clear();  
  //   add   the   header   that   specifies   the   default   filename   for   the   Download/SaveAs   dialog  
  Response.AddHeader("Content-Disposition",   "attachment;   filename="   +   file.Name);  
  //   add   the   header   that   specifies   the   file   size,   so   that   the   browser  
  //   can   show   the   download   progress  
  Response.AddHeader("Content-Length",   file.Length.ToString());  
  //   specify   that   the   response   is   a   stream   that   cannot   be   read   by   the  
  //   client   and   must   be   downloaded  
  Response.ContentType   =   "application/octet-stream";  
  //   send   the   file   stream   to   the   client  
  Response.WriteFile(file.FullName);  
  //   stop   the   execution   of   this   page  
  Response.Flush();  
   
   
   
  Top

4 楼lang11zi(微软菜虫)回复于 2003-11-04 12:37:56 得分 0

upTop

相关问题

  • 文件下载……
  • 下载文件
  • 文件下载
  • 下载文件 急!!!!!!!!!!!
  • php 文件下载
  • 文件下载,文件名乱码
  • 文件下载的文件名问题
  • 文件下载的文件名问题
  • 下载csv文件,文件名错误。
  • 如何下载Excel文件?

关键词

  • 文件
  • 下载
  • 页面
  • flush
  • specify
  • stream
  • response
  • content

得分解答快速导航

  • 帖主:michael2004

相关链接

  • CSDN .NET频道
  • .NET类图书
  • C#类图书
  • .NET类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo