예제 #1
0
 public void loadUsers()
 {
     try
     {
         using (FileStream fileStream = new FileStream("topScores.txt", FileMode.Open))
         {
             IFormatter formater = new BinaryFormatter();
             korisnici = (UsersScene)formater.Deserialize(fileStream);
             korisnici.Sort();
         }
     }
     catch (Exception ex)
     {
         korisnici = new UsersScene();
     }
 }
예제 #2
0
        private void loadHighScore()
        {
            /*  List<Score> _entities = new List<Score>();
             * var serializer = new XmlSerializer(_entities.GetType());
             * object obj;
             * using (var reader = new StreamReader("../../../SpeedBall/Resources/topScore.txt"))
             * {
             *    obj = serializer.Deserialize(reader.BaseStream);
             * }
             * _entities = (List<Score>)obj;
             *
             *
             * List<Score> _entities = new List<Score>();
             * var serializer = new XmlSerializer(_entities.GetType());
             * object obj;
             * using (var reader = new StreamReader("highscores.xml"))
             * {
             *     obj = serializer.Deserialize(reader.BaseStream);
             * }
             * _entities = (List<Score>)obj;
             *
             * List<Score> _entities = new List<Score>();
             * var serializer = new XmlSerializer(_entities.GetType());
             * object obj;
             * using (var reader = new StreamReader("../../../SpeedBall/Resources/topScore.txt"))
             * {
             *    obj = serializer.Deserialize(reader.BaseStream);
             * }
             * _entities = (List<Score>)obj;
             *
             *
             * for (int i = 0; i < _entities.Count; i++)
             * {
             *
             *     lblPreviousBest.Text += String.Format("{0}. {1}, {2} \n", i+1, _entities[i].score, _entities[i].ID);
             * } */
            UsersScene korisnici = new UsersScene();

            using (FileStream fileStream = new FileStream("topScores.txt", FileMode.Open))
            {
                IFormatter formater = new BinaryFormatter();
                korisnici = (UsersScene)formater.Deserialize(fileStream);
            }
            korisnici.Sort();
            lbUsers.Text = korisnici.ToString();
        }