protected void btnExportPDF_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(hndPdfpath.Value)) { // This is an important header part that informs the client to download this file. Response.AppendHeader("content-disposition", "attachment; filename=" + Path.GetFileName(hndPdfpath.Value)); FileInfo flnInfo = new FileInfo(hndPdfpath.Value.Trim()); if (flnInfo.Extension.ToLower() == ".xlsx" || flnInfo.Extension.ToLower() == ".xls") { Response.ContentType = "application/Excel"; } else { Response.ContentType = "Application/pdf"; } //Write the file directly to the HTTP content output stream. Response.WriteFile(hndPdfpath.Value); } }
public void DownloadFile(string filePath) { .. }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)