예제 #1
0
        public static void Serialize(Scoreinfo score)
        {
            try
            {
                using (Stream stream = File.Open("Scoreboard.bin", FileMode.Create))
                {
                    BinaryFormatter bin = new BinaryFormatter();

                    listOfAllScores.Add(score);
                    bin.Serialize(stream, listOfAllScores);
                }
            }
            catch (IOException)
            {
                MessageBox.Show("Error, can't serialize to file.");
            }
        }
예제 #2
0
        public static void writeScore(Scoreinfo score)
        {
            Serialize(score);

            EntryWindow.listBox.Items.Clear();

            sortScore();

            foreach (Scoreinfo element in listOfAllScores)
            {
                if (EntryWindow.listBox.Items.Count == 10)
                {
                    break;
                }
                EntryWindow.listBox.Items.Add(element);
            }
        }