/// <summary>
/// 下載pdf
/// </summary>
/// <param name="filepath">pdf路徑</param>
private void DownloadFile(string filepath)
{
if (File.Exists(filepath))
{
using (FileStream fs = new FileStream(filepath, FileMode.Open, FileAccess.Read))
{
byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);app
if (buffer != null && buffer.Length > 0)
{
this.Response.Clear();
this.Response.Buffer = true;
this.Response.Charset = "UTF-8"; //GB2312/UTF-8this
this.Response.AppendHeader("Content-Disposition", "attachment;filename="
+ HttpUtility.UrlEncode("document.pdf", System.Text.Encoding.UTF8));code
this.Response.ContentType = "application/octet-stream";
this.Response.BinaryWrite(buffer);
this.Response.Flush();
this.Response.End();
this.Response.Close();
}
}
}
}string