Visual Basic (Declaration) | |
---|---|
Public Overridable Function Read( _ ByVal path As String, _ ByVal name As String, _ ByRef value As String _ ) As Boolean |
Parameters
- path
- name
- value
Library/Library.Test/TestUserSettings.cs
C# | Copy Code |
---|---|
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal); UserSettingsSection section = UserSettingsSection.UserSettingsFrom(config); section["a"] = "b"; UserSettingsSubSection sec2; if (null == (sec2 = section.Sections["test.child"])) sec2 = section.Sections.Add("test.child"); sec2["a"] = "test.child.b"; config.Save(); UserSettingStorage store = new UserSettingStorage(); string value; Assert.IsTrue(store.Read("test.child", "a", out value)); Assert.AreEqual("test.child.b", value); Assert.IsTrue(store.Read("test.child", "a", out value)); Assert.AreEqual("test.child.b", value); |
VB.NET | Copy Code |
---|---|
Dim config As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal) Dim section As UserSettingsSection = UserSettingsSection.UserSettingsFrom(config) section("a") = "b" Dim sec2 As UserSettingsSubSection If Nothing = (sec2 = section.Sections("test.child")) Then sec2 = section.Sections.Add("test.child") End If sec2("a") = "test.child.b" config.Save() Dim store As New UserSettingStorage() Dim value As String Assert.IsTrue(store.Read("test.child", "a", value)) Assert.AreEqual("test.child.b", value) Assert.IsTrue(store.Read("test.child", "a", value)) Assert.AreEqual("test.child.b", value) |
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
Reference
AppSettingStorage ClassAppSettingStorage Members