Esempio n. 1
0
        private void button6_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Form1.mojalista.Clear();
                StreamReader sr = new StreamReader(dialog.FileName);
                Szkolenie    s;
                Akcja        a;
                while (!sr.EndOfStream)
                {
                    string nazwa = sr.ReadLine();
                    if (nazwa == "Akcja")
                    {
                        a = new Akcja();
                        a.Czytaj(sr);
                        Form1.mojalista.Add(a);
                    }
                    else
                    {
                        s = new Szkolenie();
                        s.Czytaj(sr);
                        Form1.mojalista.Add(s);
                    }
                }
                wczytaj = 1;
                sr.Close();
            }
        }