Thread: Configuration manager question

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    44

    Configuration manager question

    Code:
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Configuration;
    
    namespace ConsoleApplication111
    {
        class Program
        {
            static void Main(string[] args)
            {
                System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                Console.WriteLine(ConfigurationManager.AppSettings["Foo"]);
            }
        }
    }
    
    <?xml version="1.0" encoding="utf-8" ?>
    <appSettings>
    	<add key="Foo" value="Some text here"/>
    </appSettings>
    I want to read from the xml file but this does not seem to work can you help???

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    According to http://msdn.microsoft.com/en-us/libr...37(VS.80).aspx
    you should rather do something like:
    Code:
    config.Sections["Foo"]
    In your code you retrieve a config object but never use it, which is rather odd.
    Have never used these classes before though
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    44
    Does not work...It compiles but all I get is a press any key to continue...I want it to print the value from the XML

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Programming library with built in manager
    By cyreon in forum C Programming
    Replies: 5
    Last Post: 06-26-2009, 12:49 PM
  2. Templated Generic Resource Manager, WIP..
    By Shamino in forum C++ Programming
    Replies: 13
    Last Post: 02-19-2006, 06:29 PM
  3. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  4. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM
  5. Graphical interface in C ?
    By Golgot in forum C Programming
    Replies: 5
    Last Post: 11-18-2001, 04:10 PM