Click here to Skip to main content
15,911,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello everyone

i am updating configuration file with the following function
C#
private void UpdateConfig(string value)
        {
            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            //ConfigurationManager.

            AppSettingsSection appSettings = config.AppSettings as AppSettingsSection;


            
            // Get the KeyValueConfigurationCollection  
            // from the configuration.
            KeyValueConfigurationCollection settings =
              config.AppSettings.Settings;

            // Display each KeyValueConfigurationElement. 
            foreach (KeyValueConfigurationElement keyValueElement in settings)
            {
                if (keyValueElement.Key == "dbConnectionString")
                {
                    keyValueElement.Value = value;
                }
            }

            config.Save(ConfigurationSaveMode.Modified);
            ConfigurationManager.RefreshSection("appSettings");
        }

i am getting authorization exception by updating configuration file
i don't want to do that user manually change authorization on windows user level i want to make it correct in application kindly suggest me any solution.
Posted
Updated 20-Feb-13 3:22am
v2

1 solution

Try this:

C#
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900