private void browse_button1_Click(object sender, EventArgs e) { openTerrainDialog.FileName = null; openTerrainDialog.Filter = "TER文件(*.ter)|*.ter|所有文件|*.*"; openTerrainDialog.Title = "添加地形文件"; if (MainWindow.mProjectFullName != null) { //当单机确定按钮时 if (openTerrainDialog.ShowDialog() == DialogResult.OK) { //用t存放打开文件的完整路径名 locateroute_textBox2.Text = openTerrainDialog.FileName; terrainname_textBox4.Text = openTerrainDialog.FileName.Substring(openTerrainDialog.FileName.LastIndexOf('\\') + 1, openTerrainDialog.FileName.Length - 1 - openTerrainDialog.FileName.LastIndexOf('\\')); try { //如果读取的文件不存在,则会抛出异常,必须处理该异常 terrainValueStr = FileOperation.ReadLineFile(openTerrainDialog.FileName + ".terinfo", n); } catch (FileNotFoundException ex) { LogFileManager.ObjLog.fatal(ex.Message, ex); MessageBox.Show("您导入的地形文件存在错误!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } longtitude_textBox1.Text = terrainValueStr[0]; latitude_textBox3.Text = terrainValueStr[1]; MainWindow.longitudeStr = terrainValueStr[0]; MainWindow.latitudeStr = terrainValueStr[1]; //将经纬度存储到.setup.info文件中 FileOperation.WriteLineFile(SetupContent.longitudeIndeStr + " " + terrainValueStr[0], MainWindow.nodeInfoFullPath, true); FileOperation.WriteLineFile(SetupContent.latitudeIndeStr + " " + terrainValueStr[1], MainWindow.nodeInfoFullPath, true); } else { this.Close(); return; } } else { MessageBox.Show("请先创建一个工程之后再从本地添加地形!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }