Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# SharpSVN读取所有文件名_C#_Svn_File_Sharpsvn - Fatal编程技术网

C# SharpSVN读取所有文件名

C# SharpSVN读取所有文件名,c#,svn,file,sharpsvn,C#,Svn,File,Sharpsvn,在SharpSVN上仍然有点n00b,我正在寻找一些简单的代码来打开SVN存储库,并读取(至少)特定文件夹中所有文件的完整路径 假设此文件夹为\trunk\source 我不想签出或提交,只是读一个列表 我还希望读取所有文件,而不仅仅是更改的文件。好的,看起来我找到了一个方法 bool gotList; List<string> files = new List<string>(); using (SvnClient cl

在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);
                }
            }
        }
bool-gotList;
列表文件=新列表();
使用(SvnClient client=new SvnClient())
{
收集清单;
gotList=client.GetList(projectPath,out-list);
if(gotList)
{
foreach(列表中的SvnListEventArgs项)
{
添加(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");
}
SvnClient client=new SvnClient();
client.Authentication.DefaultCredentials=新的网络凭据(“svuser”、“svnpass”);
SVNURITARGE FOLDERTARGE=新SVNURITARGE(“https://mysvnserver.com/mysvnpath");
List filesFound=getFolderFiles(客户端,folderTarget);
//GetFolderFiles
//函数,在给定文件夹的SvnClient和目标后,返回文件列表
私有列表getFolderFiles(SvnClient客户端、SvnTarget folderTarget)
{
List filesFound=新列表();
列出列表结果;
if(client.GetList(folderTarget,out listResults))
{
foreach(listResults中的SvnListEventArgs项)
if(item.Entry.NodeKind==SvnNodeKind.File)
filesFound.Add(item.Path);
发现返回文件;
}
其他的
抛出新异常(“未能通过SharpSvn检索文件”);
}