Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net Sharpsvn diff方法不起作用_.net_Sharpsvn - Fatal编程技术网

.net Sharpsvn diff方法不起作用

.net Sharpsvn diff方法不起作用,.net,sharpsvn,.net,Sharpsvn,我正在尝试使用sharpsvn实现diff方法。我的代码片段如下 private void Diff(string pSourcePath) { Uri UriSCPath = new Uri(pstrSourcePath); SvnClient DPISVN_Clnt = new SvnClient(); DPISVN_Clnt.Authentication.DefaultCredentials = new NetworkCredential

我正在尝试使用sharpsvn实现diff方法。我的代码片段如下

private void Diff(string pSourcePath)
{
        Uri UriSCPath = new Uri(pstrSourcePath);
        SvnClient DPISVN_Clnt = new SvnClient();

         DPISVN_Clnt.Authentication.DefaultCredentials = new NetworkCredential("Biju","Biju");
        try
        {
            SvnRevisionRange objSvnRevisionRange=new SvnRevisionRange (17157,17161);
            Stream stream=null;
            MemoryStream objMemoryStream = new MemoryStream();
            bool b = DPISVN_Clnt.Diff(pstrSourcePath, objSvnRevisionRange, objMemoryStream);

           StreamReader strReader = new StreamReader(objMemoryStream);
            string str = strReader.ReadToEnd();
}
我的第一个问题是Diff方法在我的程序中总是返回true。我改变了我的revison范围,它也返回true

我的第二个问题是diff方法有一个输入参数名为streamresult。我认为它包含结果流信息。当我尝试使用streamreader读取结果流的内容时,它返回空字符串。但是我的修订范围不同,并且源文件中存在一些差异


使用流的方式相同吗?

正如itowlson在评论中已经回答的那样,SharpSvn将差异写入流。因此,当函数返回时,您正好位于写入的差异后面

.ReadToEnd()
读取从当前位置到结尾的所有内容,很可能什么都没有

使用

stream.Position = 0;
(或Seek)在创建流之前,读者应该提供帮助


这将为您提供一个统一的差异。如果您确实需要文件的两个版本(自己执行差异),您可以使用单独目标的
SvnClient.Write()

正如itowlson在其评论中已经回答的那样,SharpSvn将差异写入流。因此,当函数返回时,您正好位于写入的差异后面

.ReadToEnd()
读取从当前位置到结尾的所有内容,很可能什么都没有

使用

stream.Position = 0;
(或Seek)在创建流之前,读者应该提供帮助


这将为您提供一个统一的差异。如果您确实需要文件的两个版本(自己执行差异),您可以使用单独目标的
SvnClient.Write()

我不知道SharpSVN,但如果它正在写入该内存流,它可能将流指针放在了末尾。在设置读卡器之前,请尝试调用MemoryStream.Seek(0,SeekOrigin.Begin)。它还将完整路径写入diff文件,因此我必须打开它并修剪绝对路径。我不知道SharpSVN,但如果它写入该内存流,它可能将流指针保留在末尾。在设置读卡器之前,请尝试调用MemoryStream.Seek(0,SeekOrigin.Begin)。它还正在写入diff文件的完整路径,因此我必须打开它并修剪绝对路径。