从文件夹下载文件时出错,路径是使用的数据库语言

时间:2013-07-25 16:23:34

标签: c# asp.net

错误消息

"Requested URL: /selva/DDL COMMANDS.doc"

实际上我的文件路径应该是

URL:/selva/Docs/DDL COMMANDS.doc

我使用的代码:

LinkButton lnkbtn = sender as LinkButton;
GridViewRow gvrow = lnkbtn.NamingContainer as GridViewRow;
string filePath = gvDetails.DataKeys[gvrow.RowIndex].Value.ToString();
Response.ContentType = "application/doc";
Response.AddHeader("Content-Disposition", "attachment;filename=\"" + filePath + "\"");
Response.TransmitFile(Server.MapPath("~/+ filePath + "));
Response.End();

在aspx中                                                              

任何人都可能很快帮助我。 提前谢谢。

1 个答案:

答案 0 :(得分:0)

试试这个

Response.Clear();
Response.AppendHeader("content-disposition", "attachment; filename=xxxxxx.doc");
Response.ContentType = "Application/msword";
Response.WriteFile(Server.MapPath("/xxxxxxx.doc"));
Response.Flush();
Response.End();

Reference Link

相关问题