Write values in app.config file

后端 未结 10 995
生来不讨喜
生来不讨喜 2020-11-29 01:46

can anyone please help me how can I set/store values in the app.config file using c#, is it possible at all?

10条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-29 01:48

    Try the following code:

        Configuration config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);
        config.AppSettings.Settings.Add("YourKey", "YourValue");
        config.Save(ConfigurationSaveMode.Minimal);
    

    It worked for me :-)

提交回复
热议问题