• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2414
  • Last Modified:

Reading in app.config file

i am using this app.config:

<?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="TrustedSiteChanger.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" />
        </sectionGroup>
    </configSections>
    <userSettings>
        <TrustedSiteChanger.Properties.Settings>
            <setting name="Sites" serializeAs="Xml">
                <value>
                    <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                        xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                        <string>tools.reprisemedia.com</string>
                        <string>documents.reprisemedia.com</string>
                        <string>intranet.reprisemedia.com</string>
                    </ArrayOfString>
                </value>
            </setting>
        </TrustedSiteChanger.Properties.Settings>
    </userSettings>
</configuration>


how do i read in the "Sites" into a string array in C#?
0
RepriseMIS
Asked:
RepriseMIS
1 Solution
 
AgariciCommented:
you can do  AppDomain.CurrentDomain.GetData("APP_CONFIG_FILE").ToString() and get the entire file as an xml. you can then parse it using xpath for instance.

an other thing you can do is use

System.Configuration.ClientSettingsSection YourClientSettings = (System.Configuration.ClientSettingsSection)ConfigurationSettings.GetConfig( "userSettings/TrustedSiteChanger.Properties.Settings" );

i think you will chose the latest :)

hth,
A.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now