//创建存放结果集的文件夹与文件 private void CreatFile() { //启动加载xml 在debug下 xml Plate_SVM.Load(Application.StartupPath + @"\MyTestChar.xml"); Plate_Car_SVM.Load(Application.StartupPath + @"\MyTestCar.xml"); String DirectoryPath = @"C:\test-results"; if (!Directory.Exists(DirectoryPath)) { Directory.CreateDirectory(DirectoryPath); } if (File.Exists(DirectoryPath + @"\No14866mresults.txt")) { File.Delete(DirectoryPath + @"\No14866mresults.txt"); FileStream fs = new FileStream(DirectoryPath + @"\No14866mresults.txt", FileMode.Create, FileAccess.ReadWrite);//创建写入文件 file = new StreamWriter(fs); } else { FileStream fs = new FileStream(DirectoryPath + @"\No14866mresults.txt", FileMode.Create, FileAccess.ReadWrite);//创建写入文件 file = new StreamWriter(fs); } }
private void OpenXML_Click(object sender, EventArgs e) { OpenFileDialog openDlg = new OpenFileDialog(); openDlg.Filter = "XML文件|*.xml"; DialogResult dlgResult = openDlg.ShowDialog(); if (dlgResult == DialogResult.OK) { Plate_SVM.Load(openDlg.FileName); } }