Example #1
0
        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();
            });
        }
Example #2
0
        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);
        }