利用以下程式碼,即可做到以上敘述的效果。( C:\Users\David\Desktop\Download.txt 為檔案路徑 )
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment;FileName=" +
HttpUtility.UrlEncode(@"Download.txt", System.Text.Encoding.UTF8));
Response.WriteFile(@"C:\Users\David\Desktop\Download.txt");
System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest();
Response.End();
回目錄
回首頁
沒有留言 :
張貼留言