Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Run as administrator
Message
From
21/01/2011 10:46:29
Antonio Llano
Inmollano S.L.
Getxo, Spain
 
 
To
16/01/2011 16:59:32
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Environment versions
Environment:
C# 3.0
OS:
Windows 7
Network:
Windows 2008 Server
Database:
VistaDB
Application:
Desktop
Miscellaneous
Thread ID:
01496318
Message ID:
01496863
Views:
40
Thanks Craig,

The issue is that I need someway to change some AppSettings in the app.exe.config file, when the app is placed in the Program Files folder.
I have written this method to do it:
        public static void ReplaceAppSetting(String key, String value, ConfigurationUserLevel level)
        {
            Configuration config = ConfigurationManager.OpenExeConfiguration(level);
            AppSettingsSection appSection = config.AppSettings;

            if (appSection.Settings.AllKeys.Contains(key))
            {
                appSection.Settings[key].Value = value;
                config.Save(ConfigurationSaveMode.Modified);
            }
            else
            {
                AddAppSetting(key, value);
            }
        }
Usually users have administration rights but the app should be run as administrator, if not the config.Save() method fails.

I´m trying to deal with the ConfiurationPermission class but I cannot güess how to program it to an unrestricted access.

Any Idea??

Thanks.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform