Exemple #1
0
 public FormMenu()
 {
     InitializeComponent();
     lblScores.Hide();
     back.Hide();
     high = BinaryDeserializeScores();
 }
 private static void BinarySerializeScores(Highscores HS)
 {
     string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
     using (FileStream str = File.Open(path + "\\HighScoresCharInvaders.hs", FileMode.OpenOrCreate))
     {
         File.SetAttributes(path + "\\HighScoresCharInvaders.hs", File.GetAttributes(path + "\\HighScoresCharInvaders.hs") | FileAttributes.Hidden);
         BinaryFormatter bf = new BinaryFormatter();
         bf.Serialize(str, HS);
     }
 }
Exemple #3
0
        private static void BinarySerializeScores(Highscores HS)
        {
            string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            using (FileStream str = File.Open(path + "\\HighScoresCharInvaders.hs", FileMode.OpenOrCreate))
            {
                File.SetAttributes(path + "\\HighScoresCharInvaders.hs", File.GetAttributes(path + "\\HighScoresCharInvaders.hs") | FileAttributes.Hidden);
                BinaryFormatter bf = new BinaryFormatter();
                bf.Serialize(str, HS);
            }
        }
Exemple #4
0
        private static Highscores BinaryDeserializeScores()
        {
            string     path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            Highscores HS   = null;

            try
            {
                using (FileStream str = File.OpenRead(path + "\\HighScoresCharInvaders.hs"))
                {
                    BinaryFormatter bf = new BinaryFormatter();
                    HS = (Highscores)bf.Deserialize(str);
                }

                //File.Delete(path + "\\HighScoresCharInvaders.hs");

                return(HS);
            }
            catch (FileNotFoundException)
            {
                return(new Highscores());
            }
        }