TFS API Returns 只有一级文件夹 C#

TFS API Returns only first level folders C#

我正在尝试实施 TFS API 来获取所有工作项。它建立连接没有任何问题。但我面临的问题是它只能获取第一级文件夹。实际上,我要找的 fodler 就在这些文件夹中。第四层深处的某个地方。这是我正在尝试的代码

        string collectionUri = ConfigurationManager.AppSettings["tfsPath"].ToString();//http://myserver:8080/tfs/defaultcollection
        string teamProjectName = ConfigurationManager.AppSettings["tfsProject"];//mycompany

         VssConnection connection = new VssConnection(new Uri(collectionUri), new VssCredentials());

        // Create instance of WorkItemTrackingHttpClient using VssConnection
        WorkItemTrackingHttpClient witClient = connection.GetClient<WorkItemTrackingHttpClient>();

        List<QueryHierarchyItem> queryHierarchyItems = witClient.GetQueriesAsync(teamProjectName, depth:2).Result;

        foreach(QueryHierarchyItem qh in queryHierarchyItems )
        {
            string s = qh.Name;    
        }
        // Search for 'Special Queries' folder
        QueryHierarchyItem myQueriesFolder = queryHierarchyItems.FirstOrDefault(qhi => qhi.Name.Equals("Special Queries"));

这里的 queryHierarchyItems 总是 null。我尝试使用上面的 for 循环,但发现它没有进入二级文件夹。那么我怎样才能完成我的要求或者我做错了什么

如果您知道查询文件夹的路径,请使用:

var folder = witClient.GetQueryAsync(teamProject, path, depth: 1).Result;

然后您可以使用类似以下内容访问该文件夹中的查询:

var queries = folder.Children.Where(x => !x.IsFolder.GetValueOrDefault());