Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Run as administrator
Message
De
21/01/2011 10:46:29
 
 
À
16/01/2011 16:59:32
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Versions des environnements
Environment:
C# 3.0
OS:
Windows 7
Network:
Windows 2008 Server
Database:
VistaDB
Application:
Desktop
Divers
Thread ID:
01496318
Message ID:
01496863
Vues:
43
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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform