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
  • 38,279
  • 56
  • 171
  • 280
Nate Pet
  • 41,226
  • 116
  • 259
  • 398
  • 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
  • 11,681
  • 13
  • 69
  • 130
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,432
  • 4
  • 26
  • 31