string filepath = Server.MapPath("~/public/file.txt");
FileInfo fi = new FileInfo(filepath);
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + fi.Name);
Response.AddHeader("Content-Length", fi.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.Filter.Close();
Response.WriteFile(fi.FullName);
Response.End();
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/12639172/viewspace-664086/
,如需转载,请注明出处,否则将追究法律责任。