获取存储库中的文件数

时间:2013-05-22 09:54:44

标签: c# sharpsvn

如何获取存储库中的文件数? 我已经尝试过这个C#代码来获取存储库的树:

private TreeNode GetRepoTreeNodes(string currentrepourl, string currentnodepath, ref SvnClient sc)
        {
            List<TreeNode> tnkids = new List<TreeNode>();

            //using (SvnClient sc = new SvnClient())
            //{
                Collection<SvnLis​tEventArgs> repocontents = null;
                if (sc.GetList(new Uri(currentrepourl), out repocontents))
                {
                    foreach (SvnListEventArgs kiditem in repocontents)
                    {
                        if (!string.IsNullOrEmp​ty(kiditem.Path))
                        {
                            TreeNode tn = GetRepoTreeNodes(currentrepourl + @"/" + kiditem.Path, kiditem.Path, ref sc);
                            // TreeNode tn = new TreeNode(kiditem.Path, tnkids.ToArray());
                            tnkids.Add(tn);
                        }
                    }
                }
            //}

            TreeNode thenode = new TreeNode(currentnodepath, tnkids.ToArray());
            return thenode;
        }

问题是,当它到达loap的末尾时,它仍将文件视为目录,并抛出异常。我找不到解决方案。如果您有其他方法可以满足此目的,请帮助它。谢谢

1 个答案:

答案 0 :(得分:0)

查看这两个答案 - 它们应该让您对如何使用GetList()完成您正在尝试的内容有所了解:

相关问题