Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 776525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:27:50+00:00 2026-05-14T19:27:50+00:00

I have an XML file named PageData.xml in my App_Data folder. I want to

  • 0

I have an XML file named PageData.xml in my App_Data folder. I want to populate an XDocument with this file using XDocument.Load.

If I supply the full physical path it works, i.e.:

XDocument vXDoc = XDocument.Load("/Work/Project/Web/100413 Dev/App_Data/PageData.xml");

…where “Work” is a folder on my C: drive.

If I try a relative path like this, though, I get a DirectoryNotFoundException:

XDocument vXDoc = XDocument.Load("AppData/PageData.xml");

“Could not find a part of the path ‘C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0\AppData\PageData.xml’.”

This is obviously wrong, but there must be an easy way to set the correct relative path? What am I overlooking? Your help is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T19:27:51+00:00Added an answer on May 14, 2026 at 7:27 pm

    There’s a couple of ways you can do it. You can use Server.MapPath() to turn a virtual directory into a physical directory path:

    XDocument xdoc = XDocument.Load(Server.MapPath("/App_Data/PageData.xml"));
    

    Or you can use Request.PhysicalApplicationPath as well, like so:

    var path = Path.Combine(Request.PhysicalApplicationPath, "App_Data\\PageData.xml");
    XDocument xdoc = XDocument.Load(path);
    

    In either case, the problem is that the current working directory of the worker process is usually not set to the application directory (this is because working directory is a process-wide property, and a single process can host multiple web sites). More information is here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file named configuration.xml which resides in classes folder of my WEB-INF
I want to write an XML file. I have created an XSD file named
I am trying to load the XMl file using SSIS. I have My Sample
I have a method named GetOrders . This method reads an XML file and
I have a xml file named socio_form_organization.xml that have two layout's. This xml file
In my \drawable-mdpi folder, I have an image named: test.jpg In my main.xml file,
I have an xml file named Data.xml and it looks something like this <Data>
I have an XML file named list.xml in root of my site. I want
I have a bit of xml file named Sample.xml which is shown below <?xml
I have a compiled .NET assembly with a specific resource file embedded (named 'Script.xml').

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.