tags:

views:

30

answers:

1

I having an XML file and that file is under the Documents folder. If I actually give the entire path in C# then I am able to retrieve the XML values, but if I give the project path then it is not getting the values.

For example:

string fileNamePath=ConfigurationManager.AppSettings["XMLDocPath"].ToString() + fileName;
m_xmld.Load(fileNamePath);

It is throwing a runtime error.

A: 

What's the value of ConfigurationManager.AppSettings["XMLDocPath"]? Where is it defined?

It looks like you've simply got that set to the wrong value.

Also you should use Path.Combine to build up your full filename as this takes care of adding delimiters for you.

ChrisF
i configured the XML Document path in Web.config folder and here i need to give the project path like the "/projectname/documents/file.xml"like this .if i have in d: drive but it is taking as c:
Vara Prasad.M
@Vara - If you need it to be in D: you're going to have to specify it explicitly.
ChrisF
so why i required this if i kept as "D:" explicitly if i deployed the site and again i have to change the directory path each and every timeso for that reason i am asking
Vara Prasad.M
@Vara - Without the drive letter the code will assume that it's the drive of the current working directory which is usually where the application starts from. Is the application on D:?
ChrisF