參考程式碼:
String filepath = "實體路徑";
WebClient wc = new WebClient();
Response.ClearHeaders();
Response.Clear();
Response.Expires = 0;
Response.Buffer = true;
Response.AddHeader("Accept-Language", "zh-tw");
Response.AddHeader("Content-Disposition", "Attachment;FileName=" + System.Web.HttpUtility.UrlEncode(filepath, System.Text.Encoding.UTF8));
Response.ContentType = "APPLICATION/octet-stream";
Response.BinaryWrite(wc.DownloadData(filepath));
Response.End();
沒有留言:
張貼留言