XmlWriterSettings.CloseOutput Property
Gets or sets a value indicating whether the XmlWriter should also close the underlying stream or TextWriter when the Close method is called.
Namespace: System.Xml
Assembly: System.Xml (in System.Xml.dll)
Property Value
Type: System.Booleantrue to also close the underlying stream or TextWriter; otherwise, false. The default is false.
This setting is useful when you wish to write XML to a stream, and then add extra information to the end of the stream after the XmlWriter has finished writing.
This property only applies to XmlWriter instances that output XML content to a stream or TextWriter; otherwise, this setting is ignored.
The following example writes an XML fragment to a memory stream.
XmlWriterSettings settings = new XmlWriterSettings(); settings.OmitXmlDeclaration = true; settings.ConformanceLevel = ConformanceLevel.Fragment; settings.CloseOutput = false; // Create the XmlWriter object and write some content. MemoryStream strm = new MemoryStream(); XmlWriter writer = XmlWriter.Create(strm, settings); writer.WriteElementString("orderID", "1-456-ab"); writer.WriteElementString("orderID", "2-36-00a"); writer.Flush(); writer.Close(); // Do additonal processing on the stream.
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.