求大神指导啊 我的下载功能实现不了了
这是我的代码 希望众大神帮忙看看 有问题不protected void LinkButton1_Click1(object sender, EventArgs e)
{
LinkButton l = sender as LinkButton;
DownLoad();
}
public void DownLoad()
{
string filepath = Server.MapPath("~") + "/" + l.ToolTip.Substring(2, l.ToolTip.Length - 2);
if ((filepath))
{
FileInfo file = new FileInfo(filepath);
Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
Response.AddHeader("Content-Disposition", "attachment;filename=+=Server.UrlEncode(file.Name)");
Response.AddHeader("Content-Disposition", file.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(file.FullName);
Response.End();
}
}