On Wed, 03 Sep 2008 22:18:42 -0700, Pavel Minaev <in****@gmail.comwrote:
He's not passing the filename as it is - he's passing XmlReader already.
I don't know how you know that. Nor do I know why anyone would name a
variable referring to an XmlReader "file" (sounds a lot more like a
filename to me). But if that helps the OP, great.
>It does seem like the XDocument class itself ought to have a Dispose()
or
Close(), or maybe just close the source file immediately after
parsing. I
might be missing something here. :)
XDocument.Load(string) does close the file after loading it.
I'll take your word that a version of the XDocument.Load(string) method
does, but based on a previous, recent thread (StreamReader not returning
last line of text) where current behavior is obviously different from
earlier versions, I don't see how you know for sure that the OP is using a
version of .NET in which XDocument.Load(string) closes the file.
XDocument.Load(XmlReader), which is used in this case, obviously doesn't.
How do you know that XDocument.Load(XmlReader) is being used? There are
three single-parameter overloads, and even if it's known that for all
versions of .NET Load(string) closes the file, there's still
Load(TextReader) which I would think would behave a lot more like
Load(XmlReader) with respect to closing the input source when done (i.e.
not doing that).
Pete