public FormState formStateNow; //画面当前状态 /// <summary> /// 打开xml文件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOpenXml_Click(object sender, EventArgs e) { try { string filePath = UtilityFile.ChooseOneFile("xml文件|*.xml"); if (string.IsNullOrEmpty(filePath)) { return; } textBoxFileName.Text = filePath; treeView1.Nodes.Clear(); //创建一个XML对象 XmlDocument myxml = new XmlDocument(); //读取已经有的xml myxml.Load(filePath); //声明一个节点存储根节点 XmlNode root = myxml.DocumentElement; textBoxInnerText.Text = root.InnerText; TreeNode node = createNode(root); treeView1.Nodes.Add(node); } catch (Exception ex) { Log.ShowErrorBox(ex); } }
private void btnBrowser_Click(object sender, EventArgs e) { string strFile = UtilityFile.ChooseOneFile("*.xml|XML文件|*.*|所有文件"); if (string.IsNullOrEmpty(strFile.Trim())) { return; } txtXmlPath.Text = strFile; XmlTreeNode.localConfigPath = this.txtXmlPath.Text; }