public override void GetChildNodes() { if (!String.IsNullOrEmpty(FullPath)) { ChildNodes.Clear(); string[] directories = Directory.GetDirectories(FullPath); foreach (string directory in directories) { try { DirectoryTreeNode node = new DirectoryTreeNode(Path.GetFileName(directory), directory, TreeView); node.Level = Level + 1; node.TreeView = TreeView; TreeView.CheckedNodeChanged += new EventHandler <TreeNodeEventArgs>(TreeView_OnCheckedNodeChanged); node.HasChildNodes = (Directory.GetDirectories(node.FullPath).Length > 0); ChildNodes.Add(node); } catch (UnauthorizedAccessException ex) { OMLApplication.DebugLine("[DirectoryTreeNode] " + ex.Message); } catch (DriveNotFoundException ex) { OMLApplication.DebugLine("[DirectoryTreeNode] " + ex.Message); } catch (IOException ex) { OMLApplication.DebugLine("[DirectoryTreeNode] " + ex.Message); } } HasChildNodes = (ChildNodes.Count > 0); } base.GetChildNodes(); }
public override void GetChildNodes() { if (!String.IsNullOrEmpty(FullPath)) { ChildNodes.Clear(); string[] directories = Directory.GetDirectories(FullPath); foreach (string directory in directories) { try { DirectoryTreeNode node = new DirectoryTreeNode(Path.GetFileName(directory), directory, TreeView); node.Level = Level + 1; node.TreeView = TreeView; TreeView.CheckedNodeChanged += new EventHandler<TreeNodeEventArgs>(TreeView_OnCheckedNodeChanged); node.HasChildNodes = (Directory.GetDirectories(node.FullPath).Length > 0); ChildNodes.Add(node); } catch (UnauthorizedAccessException ex) { OMLApplication.DebugLine("[DirectoryTreeNode] " + ex.Message); } catch (DriveNotFoundException ex) { OMLApplication.DebugLine("[DirectoryTreeNode] " + ex.Message); } catch (IOException ex) { OMLApplication.DebugLine("[DirectoryTreeNode] " + ex.Message); } } HasChildNodes = (ChildNodes.Count > 0); } base.GetChildNodes(); }