我想把存储在Oracle数据库中的文本文件解析出来显示在界面上的DataGridView控件中,文本文件的内容如下,请大家帮忙看看,谢谢!
EportSoft Tube ... X                   Y                   Z                   R
              33.000
               0.000               0.000               0.000               0.000
              40.000              -0.000               0.000              55.000
             145.001             150.208               0.000               0.000
#eof

解决方案 »

  1.   

    File.ReadAllLines 获取所有行然后使用
    String.Split 来做把.
      

  2.   

    读进内存中,用string.split的方法写进datatable里,然后DataGridView.datasource=datatable.
      

  3.   

    我写了以下代码,可是运行时出错了,说是分隔符不能为空,请大家帮忙看看!
     using (TextFieldParser myReader = new TextFieldParser(filePath))
                        {
                            string[] currentRow;
                            this.dataGridView1.Rows.Clear();
                            while (!myReader.EndOfData)
                            {
                                try
                                {                                currentRow = myReader.ReadFields();
                                    foreach (string currentfield in currentRow)
                                    {
                                        string[] str = currentfield.Split(" ");//错误在这里 改成单引号也不行的
                                      this.dataGridView1.Rows.Add(str);
                                    }
                                }
                                catch (MalformedLineException ex)
                                {
                                    MessageBox.Show("行 " + ex.Message + " 是无效的。略过。");
                                }                        }
                        }