void AddTreeNode(TreeNode node, DirectoryEntry entry) { TreeNode subnode = node.Nodes.Add(entry.Name); subnode.Tag = entry; subnode.ContextMenu = new ContextMenu(); subnode.ContextMenu.MenuItems.Add(new MenuItem("Remove", delegate(object sender, EventArgs e) { doc.DeleteDirectoryEntry(entry); subnode.Remove(); })); foreach (KeyValuePair <string, DirectoryEntry> subentry in entry.Members) { AddTreeNode(subnode, subentry.Value); } }