private void btnLoad_Click(object sender, EventArgs e) { string dir = txtDir.Text; if (string.IsNullOrEmpty(dir)) { Utility.ShowMessage("目录不能为空!"); return; } try { FileIndex fileIndex = new FileIndex(); List <TSTreeNode> list = fileIndex.GetFileIndexList(dir); tvFileList.Nodes.Clear(); TreeNode root = new TreeNode(); TSTreeNode rootNode = list.SingleOrDefault(p => string.IsNullOrEmpty(p.PID)); if (rootNode != null) { root.Text = rootNode.Name; root.Name = rootNode.ID; root.ForeColor = Color.Blue; BindTreeNode(root, list); tvFileList.Nodes.Add(root); } } catch (Exception ex) { Utility.ShowError(ex.Message); } }