在 SharpSVN 上仍然有点 n00b,我正在寻找一些简单的代码来打开一个 SVN 存储库,并读取(至少)特定文件夹中所有文件的完整路径。
假设这个文件夹是 \trunk\source
我不想结帐或提交,只是读入列表
我还希望阅读所有文件,而不仅仅是更改的文件。
好的,看来我找到了一种方法..
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);
}
}
}
在记事本里匆匆写下这个;对不起。
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");
}