Beispiel #1
0
    static void Main(string[] args)
    {
        try
        {
            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            CustomSection sect   = (CustomSection)config.GetSection("customSection");

            foreach (string key in sect.Settings.AllKeys)
            {
                KeyValueConfigurationElement e = sect.Settings[key];
                Console.WriteLine("{0} = {1}", e.Key, e.Value);
            }
        }
        catch (Exception e)
        {
            Console.WriteLine("Exception raised: {0}\n{1}", e.GetType(), e);
        }
    }
Beispiel #2
0
    static void Main(string[] args)
    {
        try
        {
            Configuration      config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            AppSettingsSection sect   = (AppSettingsSection)config.GetSection("appSettings");

            foreach (string key in sect.Settings.AllKeys)
            {
                KeyValueConfigurationElement e = sect.Settings[key];
                Console.WriteLine("{0} = {1}", e.Key, e.Value);
            }

            Console.WriteLine("lockElements = '{0}'", sect.LockElements.AttributeList);
        }
        catch (Exception e)
        {
            Console.WriteLine("Exception raised: {0}\n{1}", e.GetType(), e);
        }
    }