protected void Button1_Click(object sender, EventArgs e)
{
Response.ContentType = "application/x-zip-compressed";
Response.AddHeader("Content-Disposition", "attachment;filename=z.zip");
string filename = Server.MapPath("z.zip");
Response.TransmitFile(filename);
}如上所示,使用Server.MapPath("z.zip") 可下载相对于WebSite项目所在磁盘路径下的文件。若想下载WebSite项目所在磁盘根目录下的文件或者下载任意磁盘目录下的文件,文件路径该怎么写呢??
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4547/viewspace-3145849/ ,如需转载,请注明出处,否则将追究法律责任。