怎么下载文件??
怎么下载文件,文件不是压缩格式.
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(scfilename, System.Text.Encoding.UTF8))
Response.WriteFile(filepath)
Response.End()
下面的程序有点问题.下载时弹出的信息不正确.下载文本文件时会自动加一串代码进去,怎么解决..
问题点数:20、回复次数:4Top
1 楼denny510(小单尼)回复于 2003-12-01 17:54:57 得分 5
呵呵,一个土办法:Response.redirect("......../aa.txt")
不过,文本文件会被打开的,
zip等文件,则会自动弹出windows下载工具Top
2 楼shang515(天天向上)回复于 2003-12-01 17:57:11 得分 8
看看这个
http://expert.csdn.net/Expert/TopicView1.asp?id=2513663Top
3 楼bhys(碧海银沙)回复于 2003-12-01 18:14:51 得分 0
我要下载的文件不是压缩格式呀Top
4 楼gasover(无尽)回复于 2003-12-01 18:57:26 得分 7
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.End();
Top




