public static void Save(ServerTransferTotal config) { try { using (StreamWriter sw = new StreamWriter(File.Open(LOG_FILE, FileMode.Create))) { string jsonString = JsonConvert.SerializeObject(config.servers, Formatting.Indented); sw.Write(jsonString); sw.Flush(); } } catch (IOException e) { Logging.LogUsefulException(e); } }
public static ServerTransferTotal Load() { try { string config_str = File.ReadAllText(LOG_FILE); ServerTransferTotal config = new ServerTransferTotal { servers = JsonConvert.DeserializeObject <Dictionary <string, ServerTrans> >(config_str) }; config.Init(); return(config); } catch (Exception e) { if (!(e is FileNotFoundException)) { Logging.LogUsefulException(e); } return(new ServerTransferTotal()); } }