private void Save() { using (var fs = new FileStream(address, FileMode.Create, FileAccess.Write)) { using (var writer = new StreamWriter(fs)) { writer.Write(Backtory.ToJson(dic)); writer.Flush(); writer.Close(); fs.Close(); } } }
private void Load() { if (!File.Exists(address)) { dic = new Dictionary <string, string>(); return; } using (var fs = new FileStream(address, FileMode.Open, FileAccess.Read)) { var reader = new StreamReader(fs); var jsonString = reader.ReadToEnd(); reader.Close(); fs.Close(); dic = Backtory.FromJson <Dictionary <string, string> >(jsonString) ?? new Dictionary <string, string>(); } }