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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:13:01+00:00 2026-06-11T02:13:01+00:00

I have the following problem trying to use a custom config section in my

  • 0

I have the following problem trying to use a custom config section in my app.config. I use a custom config section to keep track of a selection of folders that I want to back up with my program like so:

<CustomConfigSection>
    <BackupLocations>
        <clear />
        <add path="C:\Users\Marcel\Documents\" />
    </BackupLocations>
</CustomConfigSection>

Now, whenever I save the configuration file I get this exception:

System.Configuration.ConfigurationErrorsException: An error occurred
loading a configuration file: Access to the path C: \ Program Files
(x86) \ Backup Solutions \ uqhuxi1j.tmp is denied.
(C: \ Program Files (x86) \ Backup Solutions \
BS.exe.Config) —> System.UnauthorizedAccessException

The code I use is:

Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
CustomConfigSection section = (CustomConfigSection)config.GetSection("CustomConfigSection");

section.BackupLocations.Add(element);

section.SectionInformation.ForceSave = true;
config.Save(ConfigurationSaveMode.Full);

This works fine when logged in as admin and only occurs when there are multiple accounts configured on a PC, so this means it is a UAC/permissions problem. As a regular user I do not have the proper write permissions for that folder.

Now for my question(s):

How come the user settings get saved to AppData and the Custom config section is trying to save in the ApplicationFolder/exe.config? How can I make my custom section save to the AppData config file too?

I need to be able to save my data for every user, regardless of permissions. So can I achieve this using a custom config section or do I need a different approach? Preferably I would like to save my custom section into the AppData config file as well. I do not want to use tricks in my Installer to adjust permissions to my application folder to allow it to write. Most of all I do not want to require administrator permissions when starting up my program!

Thanks for your replies, much 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-06-11T02:13:02+00:00Added an answer on June 11, 2026 at 2:13 am

    After a good nights sleep I seem to have stumbled upon the answer already myself.

    The config is being saved in the AppData Directory for version and user specific data. What I was doing was actually directly opening the exe.config and not doing anything regarding user-scoped settings, let alone writing to the AppData config file for my program’s current version. When I realised this, I knew what to look for on google.

    I found these articles:

    Windows Forms – Creating and Persisting Custom User Settings in C#

    Windows Forms – Creating and Persisting Custom User Settings in C# – Part 2

    Experimenting and downloading the source files of that project helped me out a lot and provided me exactly with what I need. So basicly I was implementing the wrong functions for what I wanted to do.

    Thanks to the readers and thanks to the Mr. Ritchie for somewhat sending me into the right direction.

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

Sidebar

Related Questions

Trying to use JSTL but have the following problem: Index.xhtml page: <?xml version=1.0 encoding=UTF-8?>
I'm trying to solve the following problem in Redis. I have a list that
I'm a newbie in bash scripts and have the following problem : I'm trying
I am trying to solve the following problem with Puppet: I have multiple nodes.
I am trying to solve the following problem. Lets say you have the the
I have the following code, The problem is when I'm trying to assign the
I have a bit of a problem. I am trying to do the following
I'm trying to create a custom rule that flags up the use of return
I have a Rails app and I am trying to test it. I use
Please, I have the following problem: I'm trying to dynamically load a WCF RIA

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.