SharpSVN read ALL filenames
Asked Answered
A

2

9

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.

Aiken answered 29/6, 2009 at 23:9 Comment(0)
A
17

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);
                }
            }
        }
Aiken answered 29/6, 2009 at 23:53 Comment(0)
B
7

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");
}
Bearded answered 10/3, 2010 at 18:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.