예제 #1
0
 public FormMenu()
 {
     InitializeComponent();
     lblScores.Hide();
     back.Hide();
     high = BinaryDeserializeScores();
 }
예제 #2
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);
     }
 }
예제 #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);
            }
        }
예제 #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());
            }
        }