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

  • Home
  • SEARCH
  • 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 231731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:57:28+00:00 2026-05-11T19:57:28+00:00

I have a WPF application which saves its data to XML files in a

  • 0

I have a WPF application which saves its data to XML files in a relative-to-code directory called “Data”.

I get the relative path to the Data directory with these methods:

protected string ApplicationPath
{
    get { return System.IO.Path.GetDirectoryName(System.Reflection.Assembly
          .GetExecutingAssembly().CodeBase); }
}

protected string ApplicationDataPath
{
    get { return ApplicationPath + @"..\..\..\Data\"; }
}

public string FullXmlDataStorePathAndFileName
{
    get
    {
        return ApplicationDataPath + GetItemTypeIdCode() + ".xml";
    }
}

This works for testing since the Debug or Relates .exe will go back up into the project and access the data.

Problem #1 with this is it doesn’t work when saving the XML file, I get a “URI formats are invalid” error, it seems it can’t deal with the “……\” part of the path when saving:

xmlDoc.Save(FullXmlDataStorePathAndFileName);

Problem #2 is that when I want to deploy my app (e.g. make it available for download so someone unzips and double-clicks on the .exe), then the .xml files need to be in the same directory as the .exe or one lower in a Data directory so that each instance of the application can read and write to its own XML files.

What is the best solution for this? Requirements are:

  • XML files should be locally under the project and transparent when developing and testing, e.g. edit the XML files in Visual Studio and “Copy to Output Directory” is “Copy if Newer”, so while developing, the base data is always refreshed when press F5

  • a straight-forward way of e.g. zipping up the “Release” directory and all of the files (.exe and original XML files) are there and the paths in the .exe point to the XML files upon starting

Has anyone developed a good solution to having a local XML data source in a relative directory like this?

  • 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-11T19:57:28+00:00Added an answer on May 11, 2026 at 7:57 pm

    You could have your xml path in a separate config file?

    Or you can use conditionals (#if DEBUG / #endif) to have separate logic for your debug version.

    But I would recommend a more appropriate place for such data, something like (system disk)\Users\UserName\AppData\Roaming\AppName(etc). If your app is installed in Program Files, then your app would need additional permissions to save files there. In Vista, this would mean you would have to run your app with raised privileges, even if your account is admin (with UAP enabled).

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

Sidebar

Ask A Question

Stats

  • Questions 207k
  • Answers 207k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer the setting involved is iskeyword, which follows the same syntax… May 12, 2026 at 9:19 pm
  • Editorial Team
    Editorial Team added an answer In your control, name your Image as: <Image x:Name="someImage" Source="{Binding… May 12, 2026 at 9:19 pm
  • Editorial Team
    Editorial Team added an answer register these two events: private void image1_MouseEnter(object sender, MouseEventArgs e)… May 12, 2026 at 9:19 pm

Related Questions

I have observed some unexpected or at least not-perfectly-matching-my-needs behaviour of textboxes bound to
I am planning to create a screen saver. Thinking of trying out some WPF
I am creating a WPF/MVVM framework which generates the code for the model classes.
I'm working in WPF using the MVVM pattern, and generally things seem to be

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.