reading from app.config file

后端 未结 8 2424
不知归路
不知归路 2020-11-29 19:34

I am trying to read StartingMonthColumn and CategoryHeadingColumn from the below app.config file using the code

ConfigurationSettings.AppSettings[\"StartingM         


        
8条回答
  •  误落风尘
    2020-11-29 20:00

    ConfigurationSettings.AppSettings is obsolete, you should use ConfigurationManager.AppSettings instead (you will need to add a reference to System.Configuration)

    int value = Int32.Parse(ConfigurationManager.AppSettings["StartingMonthColumn"]);
    

    If you still have problems reading in your app settings then check that your app.config file is named correctly. Specifically, it should be named according to the executing assembly i.e. MyApp.exe.config, and should reside in the same directory as MyApp.exe.

提交回复
热议问题