2016-04-14 53 views
1

我知道这件事有一些问题,但他们都没有帮助我。找到user.confi的位置?

所以我有在其app.config中设置这样一个.NET C#应用程序:

<userSettings> 
    <MyApp.Client.Main.Properties.Settings> 
     <setting name="LoginSwitchUserRestart" serializeAs="String"> 
     <value>False</value> 
     </setting> 
     <setting name="SkinName" serializeAs="String"> 
     <value>Blue</value> 
     </setting> 
    </MyApp.Client.Main.Properties.Settings> 
    </userSettings> 

这是supose的被保存在位于此文件 C:\用户\我\ AppData的\漫游\ MyCompany_Healthcare_Systems_A \ MyApp.vshost.exe_Url_fch0ekqas3qxil4p11igflywwa1klvng \ 5.8.0.0 \ user.config

acording这个代码:

var config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.PerUserRoaming); 

MessageBox.Show(config.FilePath); 

但我没有档案?我也有几个版本的这个应用程序在Visual Studio和外部作为发行版运行,但我仍然无法找到设置文件?

操作系统是Windows 10 64位。

+0

我说好的想到哪里找做的 - 所以我做了测试中,我的是在应用程序数据\ <公司名称> \ appname.exe_ \ \ user.config - 我想知道如果这能帮助找到它programattically(还没有检查还)http://stackoverflow.com/questions/793657/how-to-find-active-app-config-file – BugFinder

+0

在我的appdata下,我只有漫游,本地和locallow。现在,当我在本地查看时,可以看到我的公司文件夹和user.config!? – Banshee

+0

遗憾是,它是在局部..所以,问题是我们可以得到它programattically根据http://stackoverflow.com/questions/621265/can-i-control-the-location-of-net-user-设置,以避免失去设置的应用程序user.config将永远是我找到它..但猜测哈希不是真的可行。还在寻找 – BugFinder

回答

0

可以具有System.configuration添加引用,并

ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath 

这个返回的路径坚持它用来user.config