Imports System.IO Imports Newtonsoft.Json.Linq Public Class AppConfig Public Property LastMinecraftProfilePath As string Public Property LastConfigFilePath As string Public Shared ReadOnly Property Instance As AppConfig Get Static myInstance As AppConfig = Nothing If myInstance Is Nothing Then If File.Exists(SettingsPath) Then myInstance = LoadConfig(SettingsPath) Else myInstance = New AppConfig End If End If Return myInstance End Get End Property Private Shared ReadOnly Property SettingsPath As string Get Static myPath As String = String.Empty Const AppDataDirectoryName As String = "MinecraftModpackUpdater" Const SettingsFileName As String = "Settings.json" If String.IsNullOrEmpty(myPath) Then myPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), AppDataDirectoryName) Directory.CreateDirectory(myPath) myPath = Path.Combine(myPath, SettingsFileName) End If Return myPath End Get End Property Public Sub SaveConfig() File.WriteAllText(SettingsPath, JObject.FromObject(Me).ToString) End Sub Private Shared Function LoadConfig(filePath As String) As AppConfig Return JObject.Parse(File.ReadAllText(filePath)).ToObject(Of AppConfig) End Function End Class