Where is ConfigurationManager's namespace?

后端 未结 7 1152
半阙折子戏
半阙折子戏 2021-01-01 09:43

I\'ve got a reference to System.Configuration - and ConfigurationSettings is found no problem - but the type or namespace \'ConfigurationMana

7条回答
  •  佛祖请我去吃肉
    2021-01-01 10:09

    I'm working in VisualStudio 2015, and ConfigurationManager is not present at System.Configuration namespace anymore.

    I was just trying to read the App.config file...

    Then I found a solution:

    Get:

    string str = MyProjectNamespace.Properties.Settings.Default["MySettingName"].ToString();
    

    Set:

    MyProjectNamespace.Properties.Settings.Default["MySettingName"]="myString";
    MyProjectNamespace.Properties.Settings.Default.Save();
    

提交回复
热议问题