Imports System.Collections.Generic
IO.File.WriteAllLines("test.txt", {"DataBaseType =1", "ServerName=LAPTOP-XXXX", "Database=mydatabase", "Connection Timeout=3000", "User ID=sa", "Password=sasa", "ServerIp=xxxx:8083", "ServiceType=http://", "Backup Driver=D:\", "Backup Folder=SWBACKUP", "Database Restore=D:\"})
Dim config = ReadConfigFile("test.txt")
Console.WriteLine(config("ServerName"))
Private Function ReadConfigFile(path As String) As Dictionary(Of String, String)
If (String.IsNullOrWhiteSpace(path)) Then
Throw New ArgumentNullException("path")
If (Not IO.File.Exists(path)) Then
Throw New ArgumentException("The file does not exist.")
Dim config = New Dictionary(Of String, String)
Dim lines = IO.File.ReadAllLines(path)
Dim separator = line.IndexOf("=")
If (separator < 0 OrElse separator = line.Length - 1) Then
Throw New Exception("The following line is not in a valid format: " & line)
Dim key = line.Substring(0, separator)
Dim value = line.Substring(separator + 1)