SharpSvn - 来自路径中的空白的例外

时间:2014-01-21 13:26:39

标签: sharpsvn

当我尝试执行某些操作时,如果指定的存储库子路径在其目录名中有空白字符,即我收到SharpSvn客户端的异常,即

https://svn.mycompan​y.com/repos/myteambl​d/MyFolder1/My Folder 2/MyFolder3

我能够通过其他应用程序访问这些路径,而SharpSvn可以非常适合非空白路径。此外,我将路径作为Uri(不是字符串)传递,因此所有空格都自动编码

以下是例外:

SharpSvn.SvnClientUnrelatedResourcesException was caught
  HResult=-2146233088
  Message=Unable to find repository location for 'https://svn.mycompan​y.com/repos/myteambl​d/MyFolder1/My%20Folder%202/MyFolder3' in revision 496637
  Source=SharpSvn
  Line=0
  OperatingSystemErrorCode=0
  SubversionErrorCode=195012
  StackTrace:
       at SharpSvn.SvnClientArgs.HandleResult(SvnClientContext client, SvnException error, Object targets) in g:\dist\src\sharpsvn\svnclientargs.cpp:line 78
       at SharpSvn.SvnClientArgs.HandleResult(SvnClientContext client, svn_error_t* error, Object targets) in g:\dist\src\sharpsvn\svnclientargs.cpp:line 42
       at SharpSvn.SvnClient.InternalLog(ICollection`1 targets, Uri logRoot, SvnRevision altPegRev, SvnLogArgs args, EventHandler`1 logHandler) in g:\dist\src\sharpsvn\commands\log.cpp:line 345
       at SharpSvn.SvnClient.Log(Uri target, SvnLogArgs args, EventHandler`1 logHandler) in g:\dist\src\sharpsvn\commands\log.cpp:line 74
       at SharpSvn.SvnClient.GetLog(Uri target, SvnLogArgs args, Collection`1& logItems) in g:\dist\src\sharpsvn\commands\log.cpp:line 402

1 个答案:

答案 0 :(得分:0)

空间在网址中无效。您应该使用而不是%20。您可以使用Uri.EscapeUriString

轻松对网址进行编码

这个电话:

var myUri="https://svn.mycompany.com/repos/myteambld/MyFolder1/My%20Folder%202/MyFolder3";
Uri.EscapeUriString(myUri);

将返回:

https://svn.mycompany.com/repos/myteambld/MyFolder1/My%20Folder%202/MyFolder3