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 149483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:08:16+00:00 2026-05-11T09:08:16+00:00

I have a set of custom XML configuration management classes in .NET. There are

  • 0

I have a set of custom XML configuration management classes in .NET.

There are two configuration scopes in my application:

User: the setting applies to the user regardless of the account she’s logged into. Stored in a XML config file in the user’s directory.

User/Account: the setting applies to the user when logged into a particular account. Stored in a XML config file in the user’s directory under an account specific sub-directory.

The two XML documents have the same structure and can be modified by hand. When the application starts up, I read the XML config from the user’s profile and the XML config from the User/Account directory. I then merge the two XML documents into a single XDocument and then deserialize the XML into objects modeled after the XDocument’s sections. If there is a User/Account-level setting present, it should override the User-level setting. Example:

User file:

<FileSettings>   <DownloadPath>C:\downloads</DownloadPath>   <UploadPath>C:\uploads</UploadPath> </FileSettings> 

User/Account file for account XYZ:

<FileSettings>   <DownloadPath>C:\newlocation\xyz\mystuff</DownloadPath> </FileSettings> 

Result after merge:

<FileSettings>   <DownloadPath>C:\newlocation\xyz\mystuff</DownloadPath>   <UploadPath>C:\uploads</UploadPath> </FileSettings> 

In the above example, a FileSettings object with 2 properties – DownloadPath and UploadPath will be instantiated from the section.

Here’s my issue: I have no idea which config file (i.e., scope) the DownloadPath and UploadPath came from. As a result, when the object needs to serialize again, it doesn’t know which properties go in which file.

Question: What’s the best way to store the ‘source,’ on a property-by-property basis, so that I can ensure a setting gets written to the same config file that it was read from?

Thanks.

  • 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. 2026-05-11T09:08:17+00:00Added an answer on May 11, 2026 at 9:08 am

    After merging, is it possible to append the value source of each properties?

    <FileSettings>   <DownloadPath>C:\newlocation\xyz\mystuff</DownloadPath>   <UploadPath>C:\uploads</UploadPath>   <DownloadPathSrc>xyz</DownloadPathSrc>   <DownloadPathSrc>user</DownloadPathSrc> </FileSettings> 

    If so, the two src properties can be deserialized into your FileSettings object, Before serialization to file again, you can create a brand new FileSetting object for each of the source WITHOUT setting the *src property, by default null string won’t be serialized by XmlSerializer. With the src property, you know which file the object you want to serialize to.

    EDIT, If you want to add src as attribute of the element. that was actually my intial thought too, however, you need create class for each of the property. e.g. for property DownloadPath in FileSetting class

    [XmlType()] public class DownloadPath {    [XmlAttribute]   public string Src;      [XmlText]   public string Text; } // serialize to <DownloadPath Src='...'>text</DownloadPath> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .NET assembly(3.5 framework) and it basically has a set of custom
I'm writing a WPF application to help non-XML-savvy customers set up configuration files on
I have a Custom List Definition (schema.xml) i have set up Site Columns (through
I have created custom listview, each row looks like my file custom_row.xml. Is there
I have a simple console application that is designed to read a custom Configuration
For my app, I have a fairly complex set of configuration options that user
I have set up a ruleset in my configuration file which has two validators,
We have set a custom 404 error page in order to display a 'nice'
I have set my default-input-method variable to english-dvorak: (custom-set-variables '(default-input-method english-dvorak)) When I launch
I have a custom UITableViewCell subclass. I have set the contentView of my cell

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.