private void LoadFileFolder_Click(object sender, EventArgs e) //文件下载 { CleanWindows(); //将窗体程序相应地方清空 searchFileText.Text = ""; //搜索框文本清空 searchFileName = ""; //将搜索名称清空 searchResult.Clear(); //清空搜索结果 allPath.Clear(); //清空所有路径 fileFolderName = openFileFolderText.Text; //保存文件夹路径 TreeViewFunction.ClearTreeView(treeView1); //每次重新兼树前将树清空 try { if (TreeViewFunction.allxmlNodeinTree != null) //如果数组非空 { TreeViewFunction.allxmlNodeinTree.Clear(); //将数组清空 }//若存储叶节点数组非空,则将数组清空 TreeViewFunction.SetManyTree(xmlName, fileFolderName, treeView1); ReadAndWriteXML.WriteFolderOrFileToXml(xmlName, fileFolderName, 2); ShowHistory(xmlName, openFileFolderText, 2);//显示历史记录 if (allPath != null) { allPath.Clear(); //请空所有路径数组 } allPath = GetallXMLNodePath(TreeViewFunction.allxmlNodeinTree); //获得当前xml文档的所有绝对路径 } catch (Exception ex) { //MessageBox.Show("error,error code:" + ex.ToString(), "Information", MessageBoxButtons.OK, MessageBoxIcon.Stop); MessageBox.Show("文件格式错误!"); TreeViewFunction.ClearTreeView(treeView1);//将树清空 } }
private void button5_Click(object sender, EventArgs e) //查找文件 { CleanWindows(); //将窗体程序相应地方清空 ReadAndWriteXML.WriteFolderOrFileToXml(xmlName, searchFileName, 3); //将历史搜索结果写入XML程序 if (searchFileName.Length == 0) //若无查找内容 { MessageBox.Show("请输入查找的内容"); } else { if (searchTreeNode != null) { searchTreeNode.ForeColor = Color.Black; //将上次选中树节点的颜色变为黑色 } treeView1.CollapseAll(); //关闭所有节点 ExpandNodes(treeView1.Nodes, searchFileName); //选择展开某节点 DataGridViewFunction.ShowSerarchResult(searchResult, dataGridView1, dataGridView2); //在DataGridView中显示结果 showw.Text = Convert.ToString(DataGridViewFunction.wCount); //lable刷新显示warning数量 showe.Text = Convert.ToString(DataGridViewFunction.eCount); //lable刷新显示error数量 } }