日期:2014-05-18 浏览次数:20604 次
string fileName = Request.PhysicalApplicationPath + 文件地址;
System.IO.FileInfo file = new System.IO.FileInfo(fileName);
UploadFile uploadFile = new UploadFile();
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(uploadFile.GetSAttachName(file.Name), Encoding.UTF8));
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(file.FullName);
------解决方案--------------------
把服务器IIS的meta设置的txt映射项删除,这样浏览器就只能下载txt,而不能打开txt了。