问题
still a bit of a n00b on SharpSVN, I'm looking to get some simple code to open up an SVN repository, and read (at least) the full path of all files in a specific folder.
Lets say that this folder is \trunk\source
I'm not looking to checkout or commit, just read into a list
I'm also looking to read ALL files, not just the changed ones.
回答1:
ok it looks like I found a method..
bool gotList;
List<string> files = new List<string>();
using (SvnClient client = new SvnClient())
{
Collection<SvnListEventArgs> list;
gotList = client.GetList(projectPath, out list);
if (gotList)
{
foreach (SvnListEventArgs item in list)
{
files.Add(item.Path);
}
}
}
回答2:
Wrote this in a hurry in notepad; Sorry.
SvnClient client = new SvnClient();
client.Authentication.DefaultCredentials = new NetworkCredential("svnuser", "svnpass");
SvnUriTarget folderTarget = new SvnUriTarget("https://mysvnserver.com/mysvnpath");
List<String> filesFound = getFolderFiles(client, folderTarget);
// GetFolderFiles
// Function that, given a SvnClient and Target to a folder, returns a list of files
private List<String> getFolderFiles(SvnClient client, SvnTarget folderTarget)
{
List<String> filesFound = new List<String>();
List<SvnListEventArgs> listResults;
if (client.GetList(folderTarget, out listResults))
{
foreach (SvnListEventArgs item in listResults)
if (item.Entry.NodeKind == SvnNodeKind.File)
filesFound.Add(item.Path);
return filesFound;
}
else
throw new Exception("Failed to retrieve files via SharpSvn");
}
来源:https://stackoverflow.com/questions/1061016/sharpsvn-read-all-filenames