如何获取存储库中的文件数?我试过这个 C# 代码来获取存储库的树:
private TreeNode GetRepoTreeNodes(string currentrepourl, string currentnodepath, ref SvnClient sc)
{
List<TreeNode> tnkids = new List<TreeNode>();
//using (SvnClient sc = new SvnClient())
//{
Collection<SvnListEventArgs> repocontents = null;
if (sc.GetList(new Uri(currentrepourl), out repocontents))
{
foreach (SvnListEventArgs kiditem in repocontents)
{
if (!string.IsNullOrEmpty(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;
}
问题是,当它到达循环末尾时,它仍然将文件视为目录并引发异常。我找不到解决方案。如果您有其他方法可以满足此目的,请提供帮助。谢谢