This is a migrated thread and some comments may be shown as answers.

XML file read in cs file

1 Answer 46 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Vishnu
Top achievements
Rank 1
Vishnu asked on 11 Oct 2011, 07:29 AM

hi friends,

i used an xml file write in one aspx file

now i need to read the content of those xml file in dummy .cs(class file)

But it gives following error,

Object reference not set to an instance of an object

while using this code

System.Web.HttpContext.Current.Server.MapPath(pathname);

pls help me

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 11 Oct 2011, 07:47 AM
Hello Vishnu,

Please make sure that the file path is correct. If it is in root folder try the following.
Server.MapPath("~/sample.xml")

Thanks,
Shinu.
Tags
General Discussions
Asked by
Vishnu
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or