public void RemoveAreas() { try { TfsTeamProjectCollection tpc = TfsConnect(); ICommonStructureService css = tpc.GetService <ICommonStructureService>(); ProjectInfo project = css.GetProjectFromName(TeamProject); NodeInfo[] hierarchy = css.ListStructures(project.Uri); XmlElement tree; if (hierarchy[0].Name.ToLower() == "area") { tree = css.GetNodesXml(new string[] { hierarchy[0].Uri }, true); } else { tree = css.GetNodesXml(new string[] { hierarchy[1].Uri }, true); } string parentUri = tree.FirstChild.Attributes["NodeID"].Value; // Enumerate nodes if (tree.HasChildNodes) { XmlNode childrenNode = tree.FirstChild; if (childrenNode.HasChildNodes && childrenNode.FirstChild.HasChildNodes) { string[] nodes = new string[childrenNode.ChildNodes[0].ChildNodes.Count]; for (int i = 0; i < childrenNode.ChildNodes[0].ChildNodes.Count; i++) { XmlNode node = childrenNode.ChildNodes[0].ChildNodes[i]; nodes[i] = node.Attributes["NodeID"].Value; } css.DeleteBranches(nodes, parentUri); } } Console.WriteLine(); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); throw; } }