本文整理汇总了VB.NET中System.Configuration.ConfigurationManager.GetSection方法的典型用法代码示例。如果您正苦于以下问题:VB.NET ConfigurationManager.GetSection方法的具体用法?VB.NET ConfigurationManager.GetSection怎么用?VB.NET ConfigurationManager.GetSection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigurationManager.GetSection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: CreateAppSettings
' Create the AppSettings section.
' The function uses the GetSection(string)method
' to access the configuration section.
' It also adds a new element to the section collection.
Public Shared Sub CreateAppSettings()
' Get the application configuration file.
Dim config As System.Configuration.Configuration = _
ConfigurationManager.OpenExeConfiguration( _
ConfigurationUserLevel.None)
Dim sectionName As String = "appSettings"
' Add an entry to appSettings.
Dim appStgCnt As Integer = _
ConfigurationManager.AppSettings.Count
Dim newKey As String = _
"NewKey" + appStgCnt.ToString()
Dim newValue As String = _
DateTime.Now.ToLongDateString() + " " + _
DateTime.Now.ToLongTimeString()
config.AppSettings.Settings.Add(newKey, _
newValue)
' Save the configuration file.
config.Save(ConfigurationSaveMode.Modified)
' Force a reload of the changed section. This
' makes the new values available for reading.
ConfigurationManager.RefreshSection(sectionName)
' Get the AppSettings section.
Dim appSettingSection As AppSettingsSection = _
DirectCast(config.GetSection(sectionName), _
AppSettingsSection)
Console.WriteLine()
Console.WriteLine( _
"Using GetSection(string).")
Console.WriteLine( _
"AppSettings section:")
Console.WriteLine( _
appSettingSection.SectionInformation.GetRawXml())
End Sub