Search code examples
c#svnsharpsvn

Retrieve information from SVN Repository contains special characters


I am using SharpSVN to connect and retrieve information from Visual SVN Server by C#.

But on SVN Server, a Repository have folder with the name is C# and when read to this folder, exception occurred:

Additional information: URL 'https://< svnserver >/svn/IT/02_SHOPFLOOR/C' non-existent in revision 13

I debug and found that URI still be:

{https://< svnserver >/svn/IT/02_SHOPFLOOR/C#} System.Uri

How could I do to access SVN repositories which contain special characters?

I had used like following but nothing changed:

if (lists[i].Path.Contains("#"))
{
     path = lists[i].Path.Replace("#", "\\#");
}
else
{
     path = lists[i].Path;
}
reposss[i] = new Uri("https://< svnserver >/svn/IT/02_SHOPFLOOR/" + path);
svnClient.GetList(reposss[i], out listsInfo); //Exception occur at here

Solution

  • The # is the schema operator in a Url. You need to escape this character using the uri escape rules. There are helper functions for this on the System.Uri class and for some specific scenarios on SvnTools. The escaped character will be something like %23 where 23 is the hexadecimal value of the character.