2009-06-29 10 views
9

wciąż trochę n00b na SharpSVN, czekam na prosty kod, aby otworzyć repozytorium SVN i odczytać (przynajmniej) pełną ścieżkę wszystkich plików w określonym folderze.SharpSVN odczytuje WSZYSTKIE nazwy plików

Powiedzmy, że ten folder jest \ trunk \ Source

Nie szukam do kasy lub dokonać, wystarczy przeczytać w liście

Jestem również patrząc na odczyt wszystkich plików, a nie tylko zmienione.

Odpowiedz

16

ok wygląda na to znalazłem sposób ..

 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); 
       } 
      } 
     } 
7

napisał to w pośpiechu w notatniku; Przepraszam.

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"); 
}