void SaveConfig() { BeamNGConfig save = new BeamNGConfig(); int.TryParse(portTextBox.Text, out save.port); string output = JsonConvert.SerializeObject(save, Formatting.Indented); File.WriteAllText(saveFilename, output); }
void LoadConfig() { if (File.Exists(saveFilename)) { string text = File.ReadAllText(saveFilename); BeamNGConfig config = JsonConvert.DeserializeObject <BeamNGConfig>(text); portTextBox.Text = "" + config.port; } }