且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在运行时保存自定义配置部分?

更新时间:2022-04-12 07:39:55

.NET确实不支持在运行时写入app.config.您可以执行此操作,但是遇到许可情况.在运行时写入app.config通常表示用户范围的配置.通常,这是通过Properties.Settings中的用户作用域配置项完成的.Settings将默认值存储在app.config中,并将新的/更改写入用户的AppData.

.NET doesn't really support writing to the app.config at runtime. You can do it, but you run into situations with permission. Writing to the app.config at runtime is generally an indication of user-scoped configuration. This is generally done with user-scoped configuration items within Properties.Settings which stores defaults in app.config and writes new/changes to the user's AppData.

就自定义配置而言,对于用户范围的设置,它实际上并不适用.您只需在设置"设计器中使用自己的类型即可.

In terms of custom configuration, with user-scoped settings, it really doesn't apply. You can simply use your own types in the Settings designer.