Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
413 views
in Technique[技术] by (71.8m points)

c# - SharpSvn: Getting repository structure and individual files

I am trying to build a simple repository browser into a web application and have been looking into using SharpSvn to help.

I can find all the usual physical commands, like update, commit, that would actually make changes to the repository or a working copy but am struggling to find a way to query a repositories structure or contents.

Is there any way I can read the structure of the repository so I can display a simple explorer like interface in a web page (i.e. tree view of directories plus a list of files)?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The SharpSvn.SvnClient class has a GetList() function that works really well:

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

Once you have the collection, you can get the path of each item at the location. You can also use the Entry object to get information concerning each item, including whether it is a directory or a file, when it was last modified, etc.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...