Reading file contents in sharpsvn

I am trying to read the contents of a .csproj file using sharpsvn, but I seem to always get an empty file.

Here is my code:

MemoryStream myOut = new MemoryStream(); svnClient.Write(path, myOut)) return myOut.GetLibsFromCsproj(); private static string GetLibsFromCsproj(this MemoryStream csjpros) { TextReader tr = new StreamReader(csjpros); XElement projectNode = XElement.Load(tr); XNamespace msbuild = "http://schemas.microsoft.com/developer/msbuild/2003"; var referenceNodes = projectNode.Descendants(msbuild + "ItemGroup").Descendants(msbuild + "Reference").ToString(); return referenceNodes; } 

When my code comes to XElement.Load(tr); , it throws an error message indicating that the root element is missing. It turns out that myOut empty.

Am I doing something wrong?

+6
source share
2 answers

Did you remember reset MemoryStream at the beginning after writing to it? Try adding this line before the return :

 myOut.Seek(0, SeekOrigin.Begin); 
+8
source

Source: https://habr.com/ru/post/917205/


All Articles