110,535
社区成员
发帖
与我相关
我的任务
分享
/// <summary>
/// (Function 文件下载)
/// </summary>
/// <param name="filePath">文件完整路径</param>
private void DownFile(string filePath)
{
try
{
FileInfo info = new FileInfo(filePath);
long fileSize = info.Length;
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Connection", "close");
Response.AddHeader("Content-Disposition", "attachement;filename=" + Path.GetFileName(filePath));
//指定文件大小
Response.AddHeader("Content-Length", fileSize.ToString());
Response.WriteFile(filePath, 0, fileSize);
Response.Flush();
Response.Close();
}
catch (Exception ex)
{
throw ex;
}
}