3

I am calling a method in C# as follows:

return Chart.RenderChartHTML("../../Charts/MSLine.swf");

The thing is that the path can be different depending on what folder I am calling RenderChartHTML from.

I tried the following so that it finds the absolute path but not working:

string mslinepath = HttpContext.Current.Server.MapPath("~/Charts/MSLine.swf");

return Chart.RenderChartHTML(mslinepath);
Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Nate Pet
  • 44,246
  • 124
  • 269
  • 414
  • Does this help? http://stackoverflow.com/questions/837488/how-can-i-get-the-applications-path-in-net-in-a-console-app – Joe Nov 07 '12 at 17:46

2 Answers2

7

You don't need the ~/. Just HttpContext.Current.Server.MapPath("Charts/MSLine.swf");

Ray Cheng
  • 12,230
  • 14
  • 74
  • 137
7

Use ResolveUrl(). It converts a URL into one that is usable on the requesting client.

So Try this instead :

string mslinepath = ResolveUrl("~/Charts/MSLine.swf")

Hope this will help !!

Kundan Singh Chouhan
  • 13,952
  • 4
  • 27
  • 32