Re: Problem with MemoryStream
From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 10/14/04
- Next message: Nicholas Paldino [.NET/C# MVP]: "Re: Word Automation"
- Previous message: Nick: "Constant Hashcode"
- In reply to: Reshma Prabhu: "Problem with MemoryStream"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 14 Oct 2004 15:52:10 +0100
Reshma Prabhu <ReshmaPrabhu@discussions.microsoft.com> wrote:
> I am trying to do an xsl tranformation from an XML file into
> another xml file. I want the output file to be in MemoryStream so that my
> dataset can direclty read xml using
> dataset.ReadXml(memoryStream).
>
> But at the time of reading it gives following exception
> System.Xml.XmlException: The root element is missing.
That's because you're writing the data to the memory stream, and then
trying to read from it without repositioning the "cursor" of the stream
to the start.
Put
mstream.Position = 0;
just before the call to ReadXml and you'll be fine.
-- Jon Skeet - <skeet@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
- Next message: Nicholas Paldino [.NET/C# MVP]: "Re: Word Automation"
- Previous message: Nick: "Constant Hashcode"
- In reply to: Reshma Prabhu: "Problem with MemoryStream"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|