日期:2014-05-17  浏览次数:21220 次

请帮我看看上面有什么错误吗?(目的打开txt,把txt存到datatable里)
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            openFileDialog1.Filter = "所有文本文件(*.txt)|*.txt";
            openFileDialog1.FileName = "";
            DialogResult result = openFileDialog1.ShowDialog();

            if (result == DialogResult.OK)
            {
                //找到需要的文本,获取了文件名
                string filepath = openFileDialog1.FileName;
                txtPath.Text = filepath;
            }

       private  DataTable MakeQQqunTable(string path)
        {
            DataColumn column1 = new DataColumn();
            column1.DataType = System.Type.GetType("System.String");
            column1.ColumnName = "QQ";
            table.Columns.Add(column1);

            DataColumn column2 = new DataColumn();
            column2.DataType = System.Type.GetType("System.String");
            column2.ColumnName = "shouji";
            table.Columns.Add(column2);

            DataColumn column3 = new DataColumn();
            column3.DataType = System.Type.GetType("System.String");
            column3.ColumnName = "guanjianci";
            table.Columns.Add(column3);



            // Instantiate the DataSet variable.
            dataSet = new DataSet();
            // Add the new DataTable to the DataSet.
            dataSet.Tables.Add(table);

            // Create three new DataRow objects and add 
            // them to the DataTable
            StreamReader reader = new StreamReader(path);