2011-03-17 92 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."); 
       } 
      } 
     } 
    }