ASP.ENT C# 文件下载函数

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# 文件下载函数)