Reputation: 6242
How can I view the content I write with XMLWriter
object to a MemoryStream
object?
Note that the MemoryStream
object isn't a member field of the class and I don't have access to it in the relevant method in which I write to it with XMLWriter
.
I thought I will be able to look at the MemoryStream
by the XMLWriter
object itself, which is linked to the MemoryStream
it writes to, but It seems that who wrote XMLWriter
didn't think about that option. :\
Thanks
Upvotes: 0
Views: 3514
Reputation: 76
I assume you would like to get string value from your MemoryStream object? Try this:
memoryStream.Position = 0;
var sr = new StreamReader(memoryStream);
var myStr = sr.ReadToEnd();
Console.WriteLine(myStr);
Upvotes: 2