public static void SaveConfig <Config> (string fullPath, Config stuff) where Config : class, new() { string dirname = Path.GetDirectoryName(fullPath); if (!string.IsNullOrEmpty(dirname)) { Directory.CreateDirectory(dirname); } File.AppendAllText(fullPath, ""); string content = PortableConfigHelper.WriteConfig(stuff: stuff); File.WriteAllText(fullPath, content); }
public static Config OpenConfig <Config> (string fullPath) where Config : class, new() { string dirname = Path.GetDirectoryName(fullPath); if (!string.IsNullOrEmpty(dirname)) { Directory.CreateDirectory(dirname); } File.AppendAllText(fullPath, ""); string content = File.ReadAllText(fullPath); Config stuff = PortableConfigHelper.ReadConfig <Config> (content: ref content); File.WriteAllText(fullPath, content); return(stuff); }