public static void saveConfig(ConfigServer Config) { try { using (StreamWriter file = File.CreateText("config.json")) { string indented = JsonConvert.SerializeObject(Config, Formatting.Indented); file.Write(indented); } } catch (Exception e) { W2Log.Write("Erro ao salvar config.json " + e.Message); return; } }
public static void ReadConfigFile(ConfigServer Config) { if (!File.Exists("config.json")) { Config = new ConfigServer(); using (StreamWriter file = File.CreateText("config.json")) { string indented = JsonConvert.SerializeObject(Config, Formatting.Indented); file.Write(indented); } } using (StreamReader r = new StreamReader("config.json")) { string json = r.ReadToEnd(); Config = JsonConvert.DeserializeObject <ConfigServer>(json); } }