如何获取当前存储库?

时间:2011-03-17 01:46:57

标签: c# sharpsvn

如何获取当前存储库的目录?

我想这样做:

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

但我不知道该目录的URI是什么,因为它之前已经检出过。如何获取给定结帐位置的URI?

1 个答案:

答案 0 :(得分: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.");
              }
           }
        }
     }