ASE Home Page Products Download Purchase Support About ASE
ChartDirector General
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Unable to save chart in my current directory using ASP.NET C#.net code
Posted by Bill Cantor on Feb-17-2013 12:44
Hi Peter,
   I cannot save my chart in my current directory using ASP.NET C# code.
This is my code:

// Output the chart
            WebChartViewer1.Image = c.makeWebImage(Chart.PNG);
            c.makeChart("Attendance.gif");


The file not shown in my directory. Please help. thanks - Bill

  Re: Unable to save chart in my current directory using ASP.NET C#.net code
Posted by Peter Kwan on Feb-18-2013 21:27
Hi Bill,

With your code, the chart should be saved in your current working directory. For most systems, the current working directory may be the directory that your program is running. Since the program you are using is the web server, it may be in the same directory as the web server executable (which is probably somewhere deep inside windows/system32). This assumes your web server (running as the anonymous user) has the privilege to write into the operating system directory.

I suspect your intention is to save the file in the directory that is mapped to your current URL path. To do this, please use the ASP.NET method Server.MapPath to convert your URL path to a file system path first. For example:

c.makeChart(Server.MapPath("Attendance.gif"));

Also, please make sure you have configured your file system security to allow the anonymous user (or the account that your ASP.NET is running under) to read/write to your directory, otherwise the file cannot be created.

For security reasons, some people will create a special "public" directory to store the image files, and only permit anonymous read/write access to that directory.

Hope this can help.

Regards
Peter Kwan