You can't. Windows Vista and 7 prohibit access to the Program Files and Windows folders unless you are logged on with Administrator rights. That's why I said to do it during install, which runs with elevated privledge.
>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.
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer