public static bool DownFile(string filePath)
    {
        try
        {
            if (File.Exists(filePath))
            {
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" + filePath);
                HttpContext.Current.Response.ContentType = "application/octet-stream";
                HttpContext.Current.Response.WriteFile(filePath);
                HttpContext.Current.Response.Flush();
                HttpContext.Current.Response.Close();
                HttpContext.Current.Response.End();
                return true;
            }
            else
            {
                return false;
            }
        }
        catch
        {
            return false;
        }
    }

相关文章:

  • 2021-05-17
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2021-06-27
  • 2022-12-23
  • 2021-09-06
  • 2021-12-03
猜你喜欢
  • 2022-12-23
  • 2021-08-30
  • 2021-08-22
  • 2021-07-21
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案