----------------------------------------------------------------------------------------------------
                                              公共点坐标
----------------------------------------------------------------------------------------------------
点名                   旧坐标(X,Y,Z)                                   新坐标(X,Y,Z)
----------------------------------------------------------------------------------------------------
GPS04  -1964734.9635   4484768.5466   4075386.7697   -1964642.8359   4484908.5860   4075486.8981
GPS30  -1967174.8023   4490401.5079   4067948.1663   -1967082.7160   4490541.6460   4068048.1509
GPS18  -1958198.6099   4481934.1931   4081954.0888   -1958106.3701   4482074.1789   4082054.3211
GPS22  -1958489.2289   4485256.3985   4077866.1343   -1958396.9949   4485396.4450   4077966.2971
GPS27  -1953456.7885   4481362.6794   4084841.9629   -1953364.4591   4481502.6550   4084942.2649
GPS26  -1958020.9950   4492625.1514   4069911.5369   -1957928.7551   4492765.3050   4070011.5630以上为TXT文件,怎么样使用StreamReader读文件,并将点名存入字符串数组,将点名对应的坐标(每一行)存入另一个二维数组。谢谢

解决方案 »

  1.   

    StreamReader sr = new StreamReader("D:/test.txt");
    循环使用sr.ReadLine()读出行
    用字符串的Split()来分隔字符串
      

  2.   

    2楼正解StreamReader sr = new StreamReader("D:/test.txt");
    循环使用sr.ReadLine()读出行
    用字符串的Split(' ')用空格分隔字符串
      

  3.   

     List<string[]> list = new List<string[]>();
        using(TextReader txt = new StreamReader("test.txt"))
        {
          string line;
          while ((line = txt.ReadLine()) != null)
          {
            list.Add(Regex.Split(line.Trim(), "\\s+"));
          }
        }
        string[][] array = list.ToArray();  
      }
    或File.ReadAllText foreach