error: Could not find a part of the path

G

Guest

Hello,
My code is this:

string fileName = "settings/tabs.xml";
XPathDocument doc = new XPathDocument(fileName);

However, instead of searching files under the current IIS directory, the IIS
give me this error:Could not find a part of the path
"C:\WINDOWS\system32\settings\tabs.xml".

Why IIS is searching for windows directory? Is there some settings went wrong?

Many Thanks

Jerry
 
G

Grant Merwitz

try this:

string fileName = Server.MapPath("settings/tabs.xml");

the reason being XPathDocument requires an exact path, not relative Web
reference

so:
"c:\InetPub\wwwroot\MySite\Settings\tabs.xml"
rather than
"settings/tabs.xml"

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top