.net 为什么下载保存的文件名是它的整个路径的名字!应该如何改
.net 为什么下载保存的文件名是它的整个路径的名字!!应该怎么改
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + Server.MapPath(x1.WenDang));
HttpContext.Current.Response.ContentType = "application/unknow";
HttpContext.Current.Response.TransmitFile(Server.MapPath(x1.WenDang));
HttpContext.Current.Response.End();
------解决方案--------------------
filename=" + Server.MapPath(x1.WenDang) 应该是这个吧 不然就是上传的时候就改了 下载又直接下
------解决方案--------------------
x1.WenDang是什么路径吗?
------解决方案--------------------
下载的方法是很多的,,你只不过使用了完整路径的下载方法。
http://wenku.baidu.com/link?url=_qQLMW1PGUulPDDhmPpiHOWU7lyiHVJerwrEqNXC7Lk3Xlgee2jFkB80ohqZOfntufpKsOeYTgf9amf8NcIGj6yzNXW6VvkjKmmkvupKwIW
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + Server.MapPath(x1.WenDang));
HttpContext.Current.Response.ContentType = "application/unknow";
HttpContext.Current.Response.TransmitFile(Server.MapPath(x1.WenDang));
HttpContext.Current.Response.End();
------解决方案--------------------
filename=" + Server.MapPath(x1.WenDang) 应该是这个吧 不然就是上传的时候就改了 下载又直接下
------解决方案--------------------
x1.WenDang是什么路径吗?
/// <summary>
/// 文件下载
/// </summary>
/// <param name="s_fileName"></param>
public static void downloadfile(string s_fileName)
{
HttpContext.Current.Response.ContentType = "application/ms-download";
string s_path = HttpContext.Current.Server.MapPath("~/") + s_fileName;
System.IO.FileInfo file = new System.IO.FileInfo(s_path);
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader("Content-Type", "application/octet-stream");
HttpContext.Current.Response.Charset = "utf-8";
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(file.Name, System.Text.Encoding.UTF8));
HttpContext.Current.Response.AddHeader("Content-Length", file.Length.ToString());
HttpContext.Current.Response.WriteFile(file.FullName);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.End();
}
------解决方案--------------------
下载的方法是很多的,,你只不过使用了完整路径的下载方法。
http://wenku.baidu.com/link?url=_qQLMW1PGUulPDDhmPpiHOWU7lyiHVJerwrEqNXC7Lk3Xlgee2jFkB80ohqZOfntufpKsOeYTgf9amf8NcIGj6yzNXW6VvkjKmmkvupKwIW