public static SimpleSetting Read() { SimpleSetting ss = null; try { string json = File.ReadAllText(settingFilename); try { ss = JsonConvert.DeserializeObject <SimpleSetting>(json); } catch (Exception ex) { ss = new SimpleSetting(); Write(ss); } } catch (FileNotFoundException ex) { ss = new SimpleSetting(); Write(ss); } return(ss); }
public static void Write(SimpleSetting ss) { var json = JsonConvert.SerializeObject(ss, Formatting.Indented); File.WriteAllText(settingFilename, json); }