Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1600
  • Last Modified:

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

0
Mike Eghtebas
Asked:
Mike Eghtebas
  • 2
  • 2
1 Solution
 
dejaanbuCommented:
chart.SaveImage(Server.MapPath("~/Images/MyChart.png"), ChartImageFormat.Png);
0
 
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

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now