Writing and reading to application settings

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rum
    New Member
    • Jul 2007
    • 1

    Writing and reading to application settings

    Hi,
    I`m writing an application that can be updated from remote server. Application config file is updating too (adding new sections etc...)
    When application is updating i make a copy of old config file and then overwrite it. Values in new config file then restored from old file:
    Code:
    setNew.Value.ValueXml.InnerXml = setOld.Value.ValueXml.InnerXml;
    where setNew and setOld are instances of SettingElement class

    after this new file is written:
    Code:
    configNew.Save(ConfigurationSaveMode.Minimal, true);
    where configNew is an instance of Configuration class

    if old value (for example Password) is an empty string it write to xml file like this

    <setting name="Password" serializeAs="St ring">
    <value>
    </value>
    this value will be read as carriage return symbol and some spaces.
    When I`m changing it manually to this:
    <setting name="Password" serializeAs="St ring">
    <value></value>
    or this:
    <setting name="Password" serializeAs="St ring">
    <value/>
    value will be read as empty string(which is needed)

    How can I force xml serialization mechanizm to use these variants of notation(for empty values)?

    Pls help.
Working...