如何访问不同应用程序的“user.config”

时间:2017-04-19 13:00:56

标签: c# migration settings

可以在C#中访问应用程序的user.config文件         ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath

现在,我需要获取DIFFERNT应用程序的user.config,该应用程序由其路径的完整路径标识,以便用该替换当前应用程序user.config。

有任何建议怎么办?

编辑:请注意我对user.config(ConfigurationUserLevel.PerUserRoamingAndLocal)感兴趣,而不是像app.config或Application.exe.config这样的应用程序级别设置。后者可以通过OpenExeConfiguration(字符串)访问,但不是我想要的。

1 个答案:

答案 0 :(得分:1)

overload that excepts a string怎么样?

length

无论如何,将你的程序集绑定到另一个程序集是一个坏主意。您应该考虑将配置文件复制到所有程序集中,并更改特定于给定程序集的部分。

编辑:由于您对特定于用户的设置感兴趣,因此您可以使用以下here

var config = ConfigurationManager.OpenExeConfiguration(pathToAssebmly);