Change the store location of application setting file [duplicate]

◇◆丶佛笑我妖孽 提交于 2020-01-05 08:01:33

问题


Possible Duplicate:
Using ConfigurationManager to load config from an arbitrary location

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

Thanks.


回答1:


You might decide to use .NET per-user(roaming) settings:

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

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.



来源:https://stackoverflow.com/questions/5657821/change-the-store-location-of-application-setting-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!