public static DyConfig GetConfig() { if (!File.Exists(filename)) { dyConfig = new DyConfig(); Save(); return(dyConfig); } FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read); byte[] buf = new byte[fs.Length]; fs.Read(buf, 0, buf.Length); fs.Close(); string jsonString = Encoding.UTF8.GetString(buf).Replace("\r", "").Replace("\n", ""); try { JObject json = JObject.Parse(jsonString); dyConfig = (DyConfig)json.ToObject(typeof(DyConfig)); return(dyConfig); } catch (Exception ex) { throw ex; } }
public static void Save(DyConfig config) { dyConfig = config; Save(); }