public static ArrayList getChildNodes(iTreeNode itn) { ArrayList nodes = new ArrayList(); String path = itn.path; DirectoryInfo dirinfo = new DirectoryInfo(path); DirectoryInfo[] child_dirinfos = dirinfo.GetDirectories(); foreach (DirectoryInfo di in child_dirinfos) { String p = di.FullName; iTreeNode n = createNode(p, NodeType.DIR); n.SelectedImageIndex = 0; n.ImageIndex = 0; n.Checked = tplDic.Contains(p) ? true : false; n.Tag = p; nodes.Add(n); } FileInfo[] child_fileinfos = dirinfo.GetFiles(); foreach (FileInfo fi in child_fileinfos) { String p = fi.FullName; iTreeNode n = createNode(p, NodeType.FILE); n.SelectedImageIndex = 1; n.ImageIndex = 1; n.Checked = tplDic.Contains(p) ? true : false; n.Tag = p; nodes.Add(n); } return(nodes); }
static iTreeNode createNode(String path, NodeType ntype) { iTreeNode itn = new iTreeNode(); itn.ntype = ntype; itn.path = path; itn.Text = getShortName(path); return(itn); }
public static iTreeNode getTreefromPath(String path, List <string> _tplDic) { tplDic = _tplDic; iTreeNode itn = createNode(path, NodeType.DIR); itn.Tag = path; itn.ChildNodesAddChildNodes(); return(itn); }
private void BindTree(string path) { //if (File.Exists(txtClientPath.Text)) //{ // MessageBox.Show("程序目录不存在!"); // return; //} treeProgram.Nodes.Clear(); iTreeNode itn = iTreeNodeManager.getTreefromPath(path, tplDic); itn.Expand(); treeProgram.Nodes.Add(itn); }