// 创建节点 private DJNode buildNode(string path) { path = path.Trim(); if (!File.Exists(path) && !Directory.Exists(path)) return null; if (isHiddenFile(path)) return null; if (File.Exists(path)) { FileInfo file = new FileInfo(path); DJNode Fnode = new DJNode(file.Name, file.FullName, true); return Fnode; } else { DirectoryInfo dir = new DirectoryInfo(path); DJNode DNode = new DJNode(dir.Name, dir.FullName, false); DirectoryInfo[] dirs = dir.GetDirectories(); for (int i = 0, len = dirs.Length; i < len; i++) { NodeHelper.add(DNode, buildNode(dirs[i].FullName)); } FileInfo[] files = dir.GetFiles(); for (int i = 0, len = files.Length; i < len; i++) { NodeHelper.add(DNode, buildNode(files[i].FullName)); } return DNode; } }
public static int add(TreeView tree, DJNode node) { if (tree == null || node == null) return -1; return tree.Nodes.Add(node); }
public static int add(DJNode parent, DJNode child) { if (parent == null || child == null) return -1; return parent.Nodes.Add(child); }
private void ffAdd(string initText, bool isFile) { DJNode selectNode = fileTree.SelectedNode as DJNode; DJNode node = new DJNode(initText, selectNode.filePath, isFile); NodeHelper.add(selectNode, node); fileTree.SelectedNode = node; node.BeginEdit(); }