【问题标题】:What is the difference between ConfigurationManager class and Settings class?ConfigurationManager 类和 Settings 类有什么区别?
【发布时间】:2011-09-09 09:02:01
【问题描述】:

ConfigurationManager 类和 Settings 类有什么区别?

我想从与我的可执行文件位于同一文件夹中的配置文件加载设置。我应该使用什么?

谢谢,

【问题讨论】:

  • 是什么样的配置文件? app.config 还是您自己的?
  • @Oskar Kjellin 我使用 app.config 文件和 Visual Studio 中的设置属性。在我的代码中,我使用 Settings.Default.ConnectionString 来获取我的值。

标签: c# configuration settings


【解决方案1】:

配置是你想要的。 Settings 类用于每个用户的可编辑设置。 (与应用程序范围的配置相反)

【讨论】:

  • 那我应该在ConfigurationManager类的OpenExeConfiguration、OpenMachineConfiguration、OpenMappedExeConfiguration、OpenMappedMachineConfiguration方法之间使用什么?
  • 取决于您存储的信息类型,以及是否可以将其包含在 app.config/web.config 的 appSettings 中。如果可以,那么“以上都不是”
猜你喜欢
  • 2010-10-16
  • 1970-01-01
  • 2010-10-02
  • 2013-11-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-07
  • 1970-01-01
相关资源
最近更新 更多