問題
使用 Response下載檔案到Client端
解決方法
private void downLoad(string filename)
{
string FilePath = Server.MapPath("~/UploadExcelTemp/" + filename);
System.IO.FileInfo TargetFile = new System.IO.FileInfo(FilePath);
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + TargetFile.Name);
Response.AddHeader("Content-Length", TargetFile.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(TargetFile.FullName);
Response.End();
}
沒有留言:
張貼留言