Export (0) Print
Expand All
Expand Minimize

XmlWriter.Close Method

When overridden in a derived class, closes this stream and the underlying stream.

Namespace:  System.Xml
Assembly:  System.Xml (in System.Xml.dll)

abstract Close : unit -> unit  
override Close : unit -> unit

ExceptionCondition
InvalidOperationException

A call is made to write more output after Close has been called or the result of this call is an invalid XML document.

InvalidOperationException

An XmlWriter method was called before a previous asynchronous operation finished. In this case, InvalidOperationException is thrown with the message “An asynchronous operation is already in progress.”

Any elements or attributes left open are automatically closed.

NoteNote

When you use the XmlWriter methods to output XML, the elements and attributes will not be written until you call the Close method. For example, if you are using the XmlWriter to populate an XmlDocument, until you close the XmlWriter, you will not be able to observe the written elements and attributes in the target document.

The following example writes an XML node.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Show:
© 2015 Microsoft