弹出下载对话框
#region 弹出下载对话框
/// <summary>
/// 打开指定的文件
/// </summary>
/// <param name="PathName">路径(相对路径)</param>
/// <param name="FileName">文件名(带扩展名)</param>
public static void OpenFile(string PathName, string FileName)
{
string name = PathName + FileName;
FileInfo aFile = new FileInfo(System.Web.HttpContext.Current.Server.MapPath(name));
string na = Path.GetFileName(name);
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.ClearHeaders();
System.Web.HttpContext.Current.Response.BufferOutput = false;
System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
System.Web.HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment;filename=" + System.Web.HttpContext.Current.Server.UrlDecode("你说的房间.zip"));
System.Web.HttpContext.Current.Response.AddHeader("Content-Length", aFile.Length.ToString());
System.Web.HttpContext.Current.Response.WriteFile(name);
System.Web.HttpContext.Current.Response.Flush();
System.Web.HttpContext.Current.Response.End();
}
#endregion 弹出下载对话框