string fileURL = this.Server.MapPath("你要下載的檔案路徑");//檔案路徑,可用相對路徑FileInfo fileInfo = new FileInfo(fileURL);Response.Clear();Response.AddHeader("content-disposition", "attachment;filename=" + Server.UrlEncode(fileInfo.Name.ToString()));//檔名Response.AddHeader("content-length", fileInfo.Length.ToString());//檔案大小Response.ContentType = "application/octet-stream";Response.ContentEncoding = System.Text.Encoding.Default;Response.WriteFile(fileURL);
string fileURL = this.Server.MapPath("你要下載的檔案路徑");//檔案路徑,可用相對路徑FileInfo fileInfo = new FileInfo(fileURL);Response.Clear();Response.AddHeader("content-disposition", "attachment;filename=" + Server.UrlEncode(fileInfo.Name.ToString()));//檔名Response.AddHeader("content-length", fileInfo.Length.ToString());//檔案大小Response.ContentType = "application/octet-stream";Response.ContentEncoding = System.Text.Encoding.Default;Response.WriteFile(fileURL);