Beispiel #1
0
        private void відкритиToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.InitialDirectory = "c:\\";
            ofd.Filter           = "Exel 3.0 files (*.exel3)|*.exel3";
            ofd.FilterIndex      = 2;
            ofd.RestoreDirectory = true;
            if (ofd.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            StreamReader sr           = new StreamReader(ofd.FileName);
            int          ColumnCount_ = 0;
            int          RowCount_    = 0;

            string[,] mass;
            if (sr.Peek() >= 0)
            {
                ColumnCount_ = Convert.ToInt32(sr.ReadLine());
            }
            else
            {
                Show a = new Show();
                a.FILEFAIL();
                return;
            }
            if (sr.Peek() >= 0)
            {
                RowCount_ = Convert.ToInt32(sr.ReadLine());
            }
            else
            {
                Show a = new Show();
                a.FILEFAIL();
                return;
            }
            if (RowCount_ * ColumnCount_ > col_d_row)
            {
                Show a = new Show();
                a.FILEFAIL();
                return;
            }
            mass = new string [ColumnCount_, RowCount_];
            for (int i = 0; i < ColumnCount_; i++)
            {
                for (int j = 0; j < RowCount_; j++)
                {
                    if (sr.Peek() >= 0)
                    {
                        mass[i, j] = sr.ReadLine();
                        if (mass[i, j] == "0")
                        {
                            mass[i, j] = "";
                        }
                    }
                    else
                    {
                        Show a = new Show();
                        a.FILEFAIL();
                        return;
                    }
                }
            }
            Ntab(ColumnCount_, RowCount_, mass);
            sr.Close();
        }