【问题标题】:Change the store location of application setting file [duplicate]更改应用程序设置文件的存储位置[重复]
【发布时间】:2011-08-05 04:41:35
【问题描述】:

可能重复:
Using ConfigurationManager to load config from an arbitrary location

我正在使用设置文件来存储我的应用程序的设置。设置文件将存储在 %AppData%\CompanyName\user.config 中。如何更改店铺位置?示例:我想将此配置文件保存在 %AppData%\CompanyName\ApplicationName\Version\user.config

谢谢。

【问题讨论】:

    标签: c# .net app-config


    【解决方案1】:

    您可能决定使用 .NET 每用户(漫游)设置:

    Configuration roamingConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoaming);
    

    根据MSDN,您不能使用 OpenExeConfiguration,因为它接受可执行文件的路径,而不是配置文件的路径。您应该将OpenMappedExeConfiguration 与包含配置文件完整路径的 ExeConfigurationFileMap 结构一起使用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-26
      • 2011-06-10
      • 1970-01-01
      • 2012-12-18
      • 2021-11-06
      • 2014-03-05
      • 2010-10-21
      • 1970-01-01
      相关资源
      最近更新 更多