|
private void But8054_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();//实例化打开一个对话框,要注意的是O大写
openFileDialog1.Filter = "文本文件(*.txt)|*.txt";//要打开的文本格式
if (openFileDialog1.ShowDialog() == DialogResult.OK) ;//判断是否打开文件
{
StreamReader Txt2 = new StreamReader(openFileDialog1.FileName);
string Txt1 = Txt2.ReadToEnd();//读取文本所有内容
string[,] data=new string [50,3] ;
string[] arrx = Txt1.Split('\r','\n');
for (int x=0;x<=arrx .Length;x ++)
{
textBox1.Text = arrx[x];
string[] arry = arrx[x].Split(' ');
for (int y=0;y <=arry .Length;y++)
{
data[x, y]= arry[y];//这里显示数组超出界限
}
}
Console.WriteLine(data);
txt文本格式
3693948.567 454937.775 26.650 j7
3694793.73 453327.997 29.165 j6
3695263.13 453329.824 27.226 j5
3695845.184 451262.869 27.430 j4
3696713.207 451254.797 27.767 j3
3697340.967 451491.317 28.025 j2
3697876.687 451210.726 27.653 j1
3697885.212 451129.276 27.651 gj
|
|