2011-03-17 94 views
1

我如何得到当前的存储库是一个目录?如何获取当前的存储库?

我想做的事:

SvnInfoEventArgs info; 
Uri repos = new Uri("http://my.server/svn/repos"); 
client.GetInfo(repos, out info); 

,但我不知道是什么的URI是目录,因为它以前签出。如何获得给定结帐位置的URI?

回答

1

我使用以下方法来从一个文件夹获取存储库URI:

 using (var folderDlg = new FolderBrowserDialog()) 
    { 
     folderDlg.Description = Resources.SelectBranchFolder; 
     folderDlg.ShowNewFolderButton = false; 
     folderDlg.RootFolder = Environment.SpecialFolder.MyComputer; 
     if (folderDlg.ShowDialog() == DialogResult.OK) 
     { 
      string workingPath = folderDlg.SelectedPath; 
      using (var svnClient = new SvnClient()) 
      { 
       Uri repo = svnClient.GetUriFromWorkingCopy(workingPath); 
       if (repo != null) 
       { 
       MessageBox.Show("The URI for this folder is " + repo.AbsoluteUri); 
       } 
       else 
       { 
       MessageBox.Show("This is not a working SVN directory."); 
       } 
      } 
     } 
    }