我有一个 C# 应用程序,我将某些值存储在设置文件中,如下所示:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="VITRIconEvacuationPlan.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="VITRIconEvacuationPlan.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<EvacuationPlan.Properties.Settings>
<setting name="AssemblyCentre" serializeAs="String">
<value>False</value>
</setting>
</EvacuationPlan.Properties.Settings>
</applicationSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup><userSettings>
<EvacuationPlan.Properties.Settings>
<setting name="SymbolScale" serializeAs="String">
<value>25</value>
</setting>
</EvacuationPlan.Properties.Settings>
</userSettings>
</configuration>
默认情况下,SymbolScale 属性设置为 25(当我第一次启动应用程序时)我想在运行时更改 SymbolScale 属性,因此我将其放入用户范围。所以我可以说:
setting.SymbolScale = 150;
setting.save();
但是当我关闭我的应用程序时,SymbolScale 的值又是 25。但我希望它从运行时存储我的 chenged 值。我究竟做错了什么?