使用 SharpSVN 读取文件时出现问题
我在使用 SharpSVN api 时遇到问题。当我尝试使用 SvnClient.Write() 或 SvnClient.Export() 时,出现以下错误:
存储库 URL 格式错误
我的代码如下
using(SvnClient client = new SvnClient())
{
MemoryStream ms = new MemoryStream();
client.Authenticator.DefaultCredentials = new NetworkCredential("master","master");
SvnTarget t1 = new SvnUriTarget(new Uri("http://ETAB-APP:81/repositorio/"));
SvnTarget t2 = new SvnUriTarget(new Uri("http://ETAB-APP:81/repositorio/Registro e Controle Acadêmico/Administração/0000/Dossiê do Aluno - ADEMIR JOSPE SANGALLI - (2001193) - Curso (000)/DOC ADICIONAL(264839).pdf"));
client.Write(t2, ms);
client.Export(t2, "C:\\chups");
}
这让我发疯,因为如果我尝试使用 t1 作为 SvnTarget 来执行此方法,一切都会正常。但问题是,每次我想获取特定文件时,我无法导出所有存储库。
我尝试在 URL 名称前添加一个“@”,即
http://@ETAB-APP:81/repositorio/Registro 学术控制/Administração/0000/Dossiê do Aluno - ADEMIR JOSPE SANGALLI - (2001193) - Curso (000)/DOC ADICIONAL(264839).pdf
但没有任何反应。
我做错了什么?
PS:抱歉,如果我犯了任何错误,我是巴西人,我的英语不是很好
I am having an issue with the SharpSVN api. When I try to use SvnClient.Write() or SvnClient.Export(), the following error occurs:
Malformed URL for repository
My code is the following
using(SvnClient client = new SvnClient())
{
MemoryStream ms = new MemoryStream();
client.Authenticator.DefaultCredentials = new NetworkCredential("master","master");
SvnTarget t1 = new SvnUriTarget(new Uri("http://ETAB-APP:81/repositorio/"));
SvnTarget t2 = new SvnUriTarget(new Uri("http://ETAB-APP:81/repositorio/Registro e Controle Acadêmico/Administração/0000/Dossiê do Aluno - ADEMIR JOSPE SANGALLI - (2001193) - Curso (000)/DOC ADICIONAL(264839).pdf"));
client.Write(t2, ms);
client.Export(t2, "C:\\chups");
}
It's driving me insane because if I try to execute this method using t1 as SvnTarget, everything works fine. But the problem is that I can't export all the repository everytime I want to get an especific file.
I tried to put an "@" before the name of URL i.e.
http://@ETAB-APP:81/repositorio/Registro e Controle Acadêmico/Administração/0000/Dossiê do Aluno - ADEMIR JOSPE SANGALLI - (2001193) - Curso (000)/DOC ADICIONAL(264839).pdf
but nothing happens.
What am I doing wrong?
PS: Sorry if I did any mistake, I am brazilian and my english is not very good
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现,如果您只是将任意 URL 传递给 Uri 对象构造函数,它将创建一个 SVN 无法理解的无效 Uri。这可能是由于外来字符或转义了默认 Uri 对象构造函数不需要转义的某些字符。
使用 UriBuilder 对象将 Uri 分解为多个部分,然后将生成的 Uri 传递给 SVN。
What I have found is that if you simply pass an arbitrary URL to the Uri object constructor, it will create an invalid Uri that SVN does not understand. This can be due to foreign characters or escaping of certain characters that does not need to be escaped by the default Uri object constructor.
Break up the Uri into its parts by using the UriBuilder object and then pass the resulting Uri to SVN.
当我调用 Sharpsvn 通过 url(包含“&”和“/”结尾)获取 svn 信息时。sharp svn 抛出异常。
谢谢斯布罗格斯:
我使用此代码
我的问题已解决。
when I call sharpsvn to get svn info by url (that contains '&',and end of '/').sharp svn throw an exception.
thanks sbrogers :
I use this code
my problem is resolved.