DanielSimons
8/7/2017 - 9:36 AM

XML Settings Reader lite

.NET integrated function for reading out values from a settings-file in the root folder.

Imports System.Configuration 
Imports System.Collections.Specialized  

Module Module1
 Sub Main()
 Dim sAttr As String
 sAttr = ConfigurationSettings.AppSettings("Key0")
 Console.WriteLine("The value of Key0: " & sAttr)
 Dim sAll As NameValueCollection
 sAll = ConfigurationSettings.AppSettings()
 Dim s As String
 For Each s In sAll.AllKeys
 Console.WriteLine("Key: " & s & " Value: " & sAll(s))
 Next
 Console.ReadLine()
 End Sub
End Module
'Filename has to be appname.exe.config and has to be in Root-Folder

<configuration>
<appSettings>
<add key="Key0" value="0"/>
<add key="Key1" value="1"/>
<add key="Key2" value="2"/>
</appSettings>
</configuration>