Error trying to read XML file

Discussion in 'ASP.NET / ASP.NET Core' started by netmail, Mar 31, 2005.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hello all,

    I am trying to read XML file using following code:

    Line 8: String xmlFilename= "School.xml";
    Line 9: DataSet newDataSet=new DataSet();
    Line 10: newDataSet.ReadXml(xmlFilename);
    Line 11: DataGrid1.DataSource=newDataSe<WBR>t;
    Line 12: DataGrid1.DataBind();

    and I get error at line 10, saying
    Could not find file "c:\windows\system32\inetsrv<WBR>\School.xml".

    I tried putting XML file in BIN and database directory, but get the same error.

    This works well in my local machine. Please help.

    Am using webmatrix and C#.

    Thanks in advance.
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    change this line

    Line 10: newDataSet.ReadXml(xmlFilename);

    to

    newDataSet.ReadXml(server.mappath('xmlFilename'));

    assuming your file is in the webroot

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  3. Thank You very much Bruce. It worked. Sorry for not responding earlier.
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page