更改应用程序设置文件的存储位置 [英] Change the store location of application setting file
问题描述
Possible Duplicate:
Using ConfigurationManager to load config from an arbitrary location
我正在使用设置文件来存储我的应用程序的设置.设置文件将存储在%AppData%\ CompanyName \ user.config中.如何更改商店位置?示例:我想将此配置文件保存在%AppData%\ CompanyName \ ApplicationName \ Version \ user.config
I'm using Setting File to store my application's settings. The setting file will be stored in %AppData%\CompanyName\user.config. How to change store location? Example: I want to save this config file in %AppData%\CompanyName\ApplicationName\Version\user.config
谢谢.
推荐答案
您可能决定使用.NET每用户(漫游)设置:
You might decide to use .NET per-user(roaming) settings:
Configuration roamingConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoaming);
根据 MSDN ,您不能使用OpenExeConfiguration因为它接受可执行文件的路径,而不是配置文件的路径.您应该将 OpenMappedExeConfiguration 与包含以下内容的ExeConfigurationFileMap结构一起使用配置文件的完整路径.
According to MSDN, you cannot use OpenExeConfiguration because it accepts path to the executable, not the path to configuration file. You should use OpenMappedExeConfiguration with ExeConfigurationFileMap structure that contains full path to configuration file.
这篇关于更改应用程序设置文件的存储位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!