我正在开发一个网站,在其中上传文档并存储在文件夹中。上传文件正常工作,但下载代码不起作用。我需要从文件夹中下载文件。
protected void btnDownload_Click(object sender, EventArgs e)
{
lblresume.Text = "~/Student_Resume/" + fuResume.FileName.ToString();
if (lblresume.Text != string.Empty)
{
string filePath = lblresume.Text;
Response.ContentType = "doc/docx";
Response.AddHeader("Content-Disposition", "attachment;filename=\"" + filePath + "\"");
Response.TransmitFile(Server.MapPath(filePath));
Response.End();
}
}