Example #1
0
        private void button6_Click(object sender, EventArgs e)
        {
            CreateFolder(@"C:\BackChat\ClassList");
            string classList = "";

            openFileDialog1.InitialDirectory = @"C:\Documents";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                classList = openFileDialog1.FileName;
                string[] str = File.ReadAllLines(classList);



                DataTable dt = new DataTable();


                string[] temp = str[0].Split(';');

                foreach (string t in temp)
                {
                    dt.Columns.Add(t, typeof(string));
                }

                for (int i = 1; i < str.Length; i++)
                {
                    string[] t = str[i].Split(';');
                    dt.Rows.Add(t);
                }

                dataGridView1.DataSource = dt;
            }
            Form2 frm2 = new Form2();

            string fileName = Path.GetFileName(classList);
            string path     = @"C:\BackChat\ClassList\" + fileName;

            frm2.Save(path, dataGridView1);
        }