|
我看了大家关于下载的代码,回去试了一下,不用工具下载的话,可以成功.但用迅雷的话下载的文件是本网页.以下是代码,望指教!!!
string name = ("Doc2\\")+"Employees.xml";
FileInfo aFile = new FileInfo(Server.MapPath(name));
string na = Path.GetFileName(name);
string hz = "." + name.Substring(name.LastIndexOf(".") + 1);//获取文件的后缀
//清除缓冲区流中的所有内容输出
Response.Clear();
Response.ClearHeaders();
Response.BufferOutput = false;
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content- disposition", "attachment;filename=" + HttpUtility.UrlEncode("baocun" + hz, Encoding.UTF8));
Response.AppendHeader("Content-Length", aFile.Length.ToString());
Response.WriteFile(aFile.FullName);
Response.End(); |
|