Use server.MapPath in a C# class
Code-behind:
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
public partial class chart : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
String pathChartFile = Server.MapPath("~/public/images/chart.png");
// Other code ...
}
// Other methods ...
}
Inside a C# class:
using System;
using System.Web;
/// <summary>
/// This class is used for managing graphs and chart
/// </summary>
public class Chart
{
public Chart()
{
String pathChartFile = HttpContext.Current.Server.MapPath("~/public/images/chart.png");
// Other code ...
}
// Other methods ...
}