image save path issue, asp.net c#

In a solution, when it is supplied with a full path as shown below it workes ok.
           chart.ChartAreas.Add(chartArea);
            string filename = "C:\\Folder1\\WebProject_1\\image\\" + chartImageName + ".png";
            chart.SaveImage(filename, ChartImageFormat.Png);

Open in new window

But because I have copied this web project to a new location, the images are still saved, understandably, at the old location.

Question: How can I change the path below to save it at new location (I am interested in relative path)?

FYI, I have tried the code below but it doesn't work.
          chart.ChartAreas.Add(chartArea);
            string filename = "~\\image\\" + chartImageName + ".png";
            chart.SaveImage(filename, ChartImageFormat.Png);

Open in new window

LVL 34
Mike EghtebasDatabase and Application DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dejaanbuCommented:
chart.SaveImage(Server.MapPath("~/Images/MyChart.png"), ChartImageFormat.Png);
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
Hi dejaanbu,

Your good code is using "Server.MapPath" which is the problem. Please see if you could help me there as well:

http://www.experts-exchange.com/Programming/Languages/.NET/Q_28496452.html

so I take care of setting Server.MapPath first.

Thanks,

Mike
0
dejaanbuCommented:
I don't think that the pbm relies with  Server.MapPath . It just returns the physical path of virtual one.
more here; http://msdn.microsoft.com/en-us/library/system.web.httpserverutility.mappath(v=vs.110).aspx
0
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
Your solution works in the original location.

Thank you,
Mike
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.