private void DownloadFiles(string strPath)
{
    FileInfo fi=new FileInfo(strPath);
    Response.Clear();
    Response.ClearHeaders();
    Response.Buffer = false;
    Response.ContentType = "application/octet-stream";
    Response.AppendHeader("Content-Disposition","attachment;filename=" +HttpUtility.UrlEncode(fi.FullName,System.Text.Encoding.UTF8));
    Response.AppendHeader("Content-Length",fi.Length.ToString());
    Response.WriteFile(fi.FullName);
    Response.Flush();
}

解决方案 »

  1.   

    另一种方式,你自己参考一下.
    try
    {
      FileStream fs = new FileStream(strPath,FileMode.Open,FileAccess.Read);
      byte[] bytes = new byte[(int)fs.Length];
      fs.Read(bytes,0,bytes.Length);//文件内容读到byte[]中
      fs.Close();
      File.Delete(strPath);
      Response.ContentType = "application/octet-stream";
      Response.AppendHeader("Content-Disposition","attachment;filename="   +HttpUtility.UrlEncode(strPath,System.Text.Encoding.UTF8));
      Response.BinaryWrite(bytes);
      Response.End();
    }
    catch(Exception e)
    {
       Response.End();
    }