Пример #1
0
        public static void Save(string path, int Entry)
        {
            BinaryIntNormal binaryIntNormalData = new BinaryIntNormal(Entry);
            BinaryFormatter saveFormater        = new BinaryFormatter();
            //Create file
            FileStream saveStream = new FileStream(path, FileMode.Create);

            //Write to file
            saveFormater.Serialize(saveStream, binaryIntNormalData);
            saveStream.Close();
        }
Пример #2
0
        public static bool Load(string path, ref int outBinaryIntNormal)
        {
            //Load
            if (File.Exists(path))
            {
                BinaryFormatter loadFormater = new BinaryFormatter();
                //Open file
                FileStream loadStream = new FileStream(path, FileMode.Open);

                //Obtain the saved data
                BinaryIntNormal binaryIntNormalData = loadFormater.Deserialize(loadStream) as BinaryIntNormal;
                loadStream.Close();

                if (binaryIntNormalData != null)
                {
                    //Copy the entries
                    outBinaryIntNormal = binaryIntNormalData.IntNormal;
                    return(true);
                }
            }
            //If loaded wrong file or file does not exist
            return(false);
        }