2010-04-21 56 views

回答

0

我对SharpSVN一无所知,但Subversion中的分支只是目录树 - 没有什么特别的。

如果您的存储库遵循它们的三个顶层目录(trunk/branches/tags /)的典型布局,那么您可以检出/ branches目录以并排获取所有分支。

-1

的SharpSvn.SvnClient类有一个的GetList()函数,作品真的很好:

using (SvnClient svnClient = new SvnClient()) 
{ 
    Collection contents; 
    List files = new List(); 
    if (svnClient.GetList(new Uri(svnUrl), out contents)) 
    { 
     foreach(SvnListEventArgs item in contents) 
     { 
      files.Add(item.Path); 
     } 
    } 
} 

一旦你的集合,可以在该位置获得每个项目的路径。您还可以使用Entry对象获取有关每个项目的信息,包括它是目录还是文件,上次修改时的文件等。

2

我认为Matt Z在正确的轨道上,但该代码doesn不会编译。这是一个调整后的版本,应该与最新版本的SharpSVN一起使用(截至2015年12月)。

using System; 
using System.Collections.Generic; 
using System.Collections.ObjectModel; 
using SharpSvn; 
.... 

private List<string> GetSVNPaths() 
{ 
    List<string> files = new List<string>(); 
    using (SvnClient svnClient = new SvnClient()) 
    { 
    Collection<SvnListEventArgs> contents; 
    //you can get the url from the TortoiseSVN repo-browser if you aren't sure 
    if (svnClient.GetList(new Uri(@"https://your-repository-url/"), out contents)) 
    { 
     files.AddRange(contents.Select(item => item.Path)); 
    } 
    } 
    return files; 
} 
相关问题