3
我有這個配置文件如何檢索從userSettings部分在C#中的價值
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="DynamicFormWorker.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<userSettings>
<DynamicFormWorker.Properties.Settings>
<setting name="mandator" serializeAs="String">
<value>$$mandator$$</value>
</setting>
</DynamicFormWorker.Properties.Settings>
</userSettings>
<appSettings>
<add key="log4net.Config" value="log4net.config" />
<add key="ClientSettingsProvider.ServiceUri" value="" />
</appSettings>
<system.web>
<membership defaultProvider="ClientAuthenticationMembershipProvider">
<providers>
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
</providers>
</membership>
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
<providers>
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
</providers>
</roleManager>
</system.web>
</configuration>
現在我想通了如何在C#中加載一個具體的配置文件,但實際上我沒有得到我的價值強制要素。
我加載的exe配置這樣
configLocation = new ExeConfigurationFileMap();
configLocation.ExeConfigFilename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App.config");
exeConfig = ConfigurationManager.OpenMappedExeConfiguration(configLocation, ConfigurationUserLevel.None);
但我怎麼檢索userSettings裏面的委託人元素?由於
雖然這個問題舉行會談寫入userSettings,它可能仍然是有趣的:http://stackoverflow.com/questions/629143/how-to-write-to-the-main-exes-config-usersettings-section – neontapir