Add data to DataTable columns in multiple text files
<p>I'm trying to export data in multiple files to a single datatable. I was able to add data to the dataset but it doesn't provide the output that I need. I guess it should be an error in my loop and I tried in different ways but failed to get the correct output. Given below the output that I receive:</p>

<p><img src="http://i.stack.imgur.com/XaFIN.png" alt="enter image description here"> </p>

<p>And this is the output I need:</p>

<p><img src="http://i.stack.imgur.com/WLHxz.png" alt="enter image description here"></p>

<p>Please refer the coding that i use and please help me to find where i go wrong. Thanks in advance</p>

<pre><code>OpenFileDialog thisDialog = new OpenFileDialog();
        thisDialog.Multiselect = true;
        DataTable dt = new DataTable();

        if (thisDialog.ShowDialog() == DialogResult.OK)
        {
            foreach (string files in thisDialog.FileNames)
            {
                //each file generates two columns
                DataColumn column1 = new DataColumn();
                dt.Columns.Add(column1);
                DataColumn column2 = new DataColumn();
                dt.Columns.Add(column2);
                using (System.IO.StreamReader file = new System.IO.StreamReader(files))
                {
                    string line;
                    while ((line = file.ReadLine()) != null)
                    {
                        if (line.Contains("DISKXFER"))
                        {
                            string dataLine = line.ToString();
                            string[] split = dataLine.Split(',');
                            int result = split.Length;
                            DataRow row = dt.NewRow();
                            dt.Rows.Add(split[2], split[3]);
                        }
                    }
                }
            }
            dataGridView1.DataSource = dt;
        }
</code></pre>
