//呼叫方法
DownloadFile("applyform.doc", System.IO.File.ReadAllBytes(context.Server.MapPath("/temp/applyfrm.doc")));
///
/// 下載Word檔
///
/// 另存新檔的檔名
/// Word檔內容
private void DownloadFile(string FileNameWhenUserDownload, byte[] FileContent)
{
Response.ClearHeaders();
Response.Clear();
Response.Expires = 0;
Response.Buffer = true;
Response.AddHeader("Accept-Language", "zh-tw");
Response.AddHeader("content-disposition", "attachment; filename=" + FileNameWhenUserDownload);
Response.ContentType = "Application/msword";
Response.BinaryWrite(FileBody);
Response.End();
}
沒有留言:
張貼留言