Reset/Save Chart Image? Getting Error? RRS feed

  • Question

  • Hi,

    Every search , DataGrid and winform chart got updated as per result.At same time chart image has been stored in folder.

    At first its working fine and chart image saved and after second time search , getting error it states that "The process cannot access the file 'c:\Excel\RHSCount.png' because it is being used by another process."

    Code :

                    //CREATE FILES
                    chartRHS_Count.SaveImage(@"c:\Excel\RHSCount.png", ChartImageFormat.Png);

    I want reset and update the chartimage from same path.Please help me

    Friday, January 4, 2019 5:42 PM

All replies

  • What happen with this file later?

    (For example, if it is loaded into Picture Box, then use the ImageLocation property instead of Image).

    Friday, January 4, 2019 6:59 PM
  • Actually export to excel with Chart, it get image from folder.
     Unable to update or delete image from image folder and getting error.

    • Edited by .netNaga Saturday, January 5, 2019 3:20 AM
    Saturday, January 5, 2019 3:17 AM
  • If you cannot close the Excel and dispose all of the objects, then maybe use different names (“RHSCount1.png”, “RHSCount2.png”, etc.) before re-exporting the chart.

    Saturday, January 5, 2019 7:36 AM
  • <style type="text/css">@page { margin: 2cm } p { margin-bottom: 0.25cm; line-height: 120% } code.cjk { font-family: "DejaVu Sans Mono", monospace } a:link { so-language: zxx } </style>

    You may try this code:

    <telerik:RadHtmlChart ID="RadHtmlChart1" runat="server"></telerik:RadHtmlChart> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" /> protected void Page_Load(object sender, EventArgs e)  {    ColumnSeries series1 = new ColumnSeries();    series1.Name = "IE";    series1.Stacked = true;    SeriesItem SeriesItem11 = new SeriesItem();    SeriesItem11.YValue =0;    SeriesItem SeriesItem12 = new SeriesItem();    SeriesItem12.YValue = 0;    SeriesItem SeriesItem13 = new SeriesItem();    SeriesItem13.YValue = 48;    SeriesItem SeriesItem14 = new SeriesItem();    SeriesItem14.YValue = 41;    SeriesItem SeriesItem15 = new SeriesItem();    SeriesItem15.YValue = 34;    series1.Items.Add(SeriesItem11);    series1.Items.Add(SeriesItem12);    series1.Items.Add(SeriesItem13);    series1.Items.Add(SeriesItem14);    series1.Items.Add(SeriesItem15);    RadHtmlChart1.PlotArea.Series.Add(series1);  } protected void Button1_Click(object sender, EventArgs e)  {    RadHtmlChart1.PlotArea.Series.Clear();  }

    Saturday, January 5, 2019 8:08 AM
  • Hi Himanshu Manghani,

    Thank you for posting here.

    For your issue, I have made a simple code demo for your reference.

    private void Form1_Load(object sender, EventArgs e)
                chart1.Series[0].XValueMember = "product";
                chart1.Series[0].YValueMembers = "price";
                chart1.SaveImage(@"C:\new.png", ChartImageFormat.Png);
            private void button1_Click(object sender, EventArgs e)
                foreach (var item in chart1.Series)
                chart1.Series[0].XValueMember = textBox1.Text;
                chart1.Series[0].YValueMembers = textBox2.Text;
                chart1.SaveImage(@"C:\new.png ,ChartImageFormat.Png);
            private void load()
                string strcon = @"Data Source=(localdb)\ProjectsV13;Initial Catalog=example;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";
                SqlConnection sqlConnection = new SqlConnection(strcon);
                string sql = "select*from test1";
                SqlDataAdapter sda = new SqlDataAdapter(sql, sqlConnection);
                DataSet dataSet = new DataSet();
                sda.Fill(dataSet, "Test");
                DataTable table = dataSet.Tables["Test"];
                chart1.DataSource = table;

    Test Result:

    Hope my suggestions could be helpful.

    Best regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Monday, January 7, 2019 9:38 AM