public static async void WriteLocalData(LocalData data) { await Task.Run(() => { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Create); formatter.Serialize(stream, data); stream.Close(); }); }
private static LocalData ReadLocalData() { if (!File.Exists(path)) { return(null); } BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); LocalData data = formatter.Deserialize(stream) as LocalData; stream.Close(); return(data); }