using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Text.Json; using System.Text.Json.Serialization; using System.IO; namespace PlaylistManager { public class Settings { public List ReplacePathList = new(); internal void Save(string Filename) { string json = JsonSerializer.Serialize(this); File.WriteAllText(Filename, json); } internal static Settings Load(string Filename) { Settings? result; if (File.Exists(Filename)) { string json = File.ReadAllText(Filename); result = JsonSerializer.Deserialize(json); } else { result = new Settings(); } if (result == null) throw new Exception($"Invalid content for settingsfile in '{Filename}'"); return result; } } public class ReplacePathItem { internal string OriginalPath { get; set; } = null!; internal string ReplacePath { get; set; } = null!; } }