In ASPX code behind, we can use Server.MapPath to get the absolute path but in C# class of an web application we need to use HttpContext.Current.Server.MapPath instead.
For example:
string FilePath = Path.Combine(HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["PDFs"].ToString()), "Jobs.pdf"); |