Esempio n. 1
0
        private void buttonImport_Click(object sender, EventArgs e)
        {
            clearThemAll();

            openFileDialog1.ShowDialog();
            string path = openFileDialog1.FileName;

            if (path == "openFileDialog1")
            {
                return;
            }
            else if (!path.EndsWith(".xml"))
            {
                MessageBox.Show("To nie jest plik .xml", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            questionArray = LoadXML.LoadData(path);
            Enable();

            if (questionArray != null)
            {
                fillListBox();
                loadQuestion(0);
                maxScore();
            }
        }
Esempio n. 2
0
        public static ArrayOfQuestion LoadData(string path)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(ArrayOfQuestion));

            FileStream      fs     = new FileStream(path, FileMode.Open);
            ArrayOfQuestion result = (ArrayOfQuestion)serializer.Deserialize(fs);

            fs.Close();

            return(result);
        }