Question

I am busy working on a piece of software which stores a .config file within the installation folder (C:/Program Files/...). This config file needs to be updated when the software is used which currently works fine when the user has Admin rights, however when a non-admin user attempts to use the software exceptions occur since they don't have permission to update files within C:/Program Files/.

The code used to update the config file is as follows:

Configuration config = ConfigurationManager.OpenExeConfiguration(fileName);
config.AppSettings.Settings.Add("New Setting");
config.Save();

Is there anyway to allow a non-admin user to update this config file? Maybe by changing something in the actual config file or changing the way in which I update it?

Ideally I would move the file to the App Data folder but this could be a fair bit of work so I would prefer to avoid having to do this.

Any help would be greatly appreciated.

Thanks in advance

Was it helpful?

Solution

Your installer (or even the app, when it detects it's run as an admin) could set the ACLs on the configuration file to allow normal users to read and write that particular file.

However the right way to do this - as you said yourself - is to use the application data folder.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top