All pastes #608350 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-07-08 07:10 UTC
rendered paste body
        public static void Serialize()
        {
            try
            {
                byte[] byteMap = CompressMyObject(myMap);
                Stream stream = File.Open(@"C:\blah.dat", FileMode.Create);
                BinaryFormatter bFormatter = new BinaryFormatter();

                bFormatter.Serialize(stream, byteMap);
                stream.Close();
                bFormatter = null;
                
            }
            catch (InvalidOperationException e)
            {
                MessageBox.Show(e.ToString());
            }
        }

        public static void Deserialize()
        {
            try
            {
                byte[] byteMap;
                Stream stream = File.Open(@"C:\blah.dat", FileMode.Open);
                BinaryFormatter bFormatter = new BinaryFormatter();

                byteMap = (byte[])bFormatter.Deserialize(stream);
                myMap = DecompressMyObject(byteMap);
                stream.Close();
                bFormatter = null;

            }
            catch (InvalidOperationException e)
            {
                MessageBox.Show(e.ToString());
            }
        }