Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Changing App.Config at runtime.
Message
De
03/03/2010 11:15:17
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Installation et Configuration
Titre:
Changing App.Config at runtime.
Divers
Thread ID:
01452269
Message ID:
01452269
Vues:
98
I have an app.config file with a tag for an email address. I'd like to change the email address at runtime and have it saved to the config file. Any ideas on how to do this?

Here's my codel:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="FlexTime.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
        </sectionGroup>
    </configSections>
  <connectionStrings>
    <add name="FlexTime.Properties.Settings.InCheckConnectionString"
      connectionString="Data Source=SVNYDBSQLDEV1;Initial Catalog=InCheck;Integrated Security=True"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
  <appSettings>
        <add key="server" value="172.16.202.66" />
        <add key="supvemail" value="jweil@nyhomes.org" />
        <add key="title" value="FlexTime" />
        <add key="conString" value="Initial Catalog=InCheck;Data Source=SVNYDBSQLDEV1;Integrated Security=SSPI;" />
    </appSettings>
  <userSettings>
    <FlexTime.Properties.Settings>
      <setting name="supvemail" serializeAs="String">
        <value>jweil@nyhomes.org</value>
      </setting>
      <setting name="title" serializeAs="String">
        <value>FlexTime</value>
      </setting>
    </FlexTime.Properties.Settings>
  </userSettings>
</configuration>
The code in my form.cs is this:

ConfigurationSettings.AppSettings["supvemail"] = this.txtSupervisorEmail.Text.Trim();

The value isn't saved and reverts back to the old application setting once the application is relaunched.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform