请教关于文件下载的问题
如果在页面点击文件下载时,如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




