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;
}
}
【原创】ASP.ENT C# 文件下载函数
最新推荐文章于 2022-09-27 20:47:56 发布