string strFilename_org=@"B:\1402\tmuninst1402.ini";System.IO.FileInfo file = new System.IO.FileInfo(strFilename_org);
Response.Clear();
string filename=@"e:\bak\"+strFilename_org;
filename=HttpUtility.UrlEncode(filename).Replace('+',' ');
Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType ="text/html";
Response.WriteFile(file.FullName);
Response.End();
Page.RegisterStartupScript("alert","<script language='javascript'> alert('文件成功下载!!')</script>");

解决方案 »

  1.   

    Response.Clear();
    Response.ContentType = strContentType;
    Response.AppendHeader("content-disposition","attachment;filename="+strFileName);
    Response.WriteFile(Request.PhysicalApplicationPath+strExportFileName);
    System.IO.File.Delete(Request.PhysicalApplicationPath+strExportFileName); // delete the exported file from the disk 
    Response.Close(); 
      

  2.   

    Response.Close(); --> Response.End();
      

  3.   

    Response.Close(); --> Response.End();
      

  4.   

    aspx页面改:<%@Page Language="C#" AutoEventWireUp="false"%>aspx.cs页面:Page_Load()
    {
      if(!IsPostback)
      {
       try
       {
          //把你的读文件等代码写到这里
       }
       catch
       {
         Response.End();
       }
      }
    }
      

  5.   

    to panyee(快乐王子)除了这种下载方法,还有别的吗?http的除外