if (e.CommandName == "downLoad") { DataTable dt = new DataTable(); Int32 id = Convert.ToInt32(e.CommandArgument); p.Admin_Flag = 8; p.Id = id; p.DateFrom_Sorting = System.DateTime.Now; p.DateTo_Sorting = System.DateTime.Now; dt = b.Job_Applied_GridShow(p); if (dt.Rows.Count > 0) { string filepath = "~/" + dt.Rows[0]["file_path"].ToString(); //....................................................... string path = Server.MapPath(filepath); //get physical file path from server string name = Path.GetFileName(path); //get file name string ext = Path.GetExtension(path); //get file extension string type = ""; // set known types based on file extension if (ext != null) { switch (ext.ToLower()) { case ".pdf": type = "Application/pdf"; break; case ".doc": type = "Application/msword"; break; case ".docx": type = "Application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; case ".rtf": type = "Application/msword"; break; Default: type = ""; break; } } Response.AppendHeader("content-disposition", "attachment; filename=" + name); if (type != "") { Response.ContentType = type; Response.Flush(); Response.WriteFile(path); Response.End(); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)