XmlWriterSettings.CloseOutput Właściwość

Definicja

Pobiera lub ustawia wartość wskazującą, czy XmlWriter obiekt powinien również zamknąć bazowy strumień, czy TextWriter też po wywołaniu Close() metody.

public:
 property bool CloseOutput { bool get(); void set(bool value); };
public bool CloseOutput { get; set; }
member this.CloseOutput : bool with get, set
Public Property CloseOutput As Boolean

Wartość właściwości

true aby również zamknąć strumień źródłowy lub TextWriter; w przeciwnym razie false. Wartość domyślna to false.

Przykłady

Poniższy przykład zapisuje fragment XML w strumieniu pamięci.

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 additional processing on the stream.
Dim settings As XmlWriterSettings = New XmlWriterSettings()
settings.OmitXmlDeclaration = true
settings.ConformanceLevel = ConformanceLevel.Fragment
settings.CloseOutput = false

' Create the XmlWriter object and write some content.
Dim strm as MemoryStream = new MemoryStream()
Dim writer As XmlWriter = XmlWriter.Create(strm, settings)
writer.WriteElementString("orderID", "1-456-ab")
writer.WriteElementString("orderID", "2-36-00a")
writer.Flush()
writer.Close()

' Do additional processing on the stream.

Uwagi

To ustawienie jest przydatne, gdy chcesz zapisać kod XML w strumieniu, a następnie dodać dodatkowe informacje na końcu strumienia po zakończeniu XmlWriter pisania.

Ta właściwość dotyczy XmlWriter tylko wystąpień, które wysyłają zawartość XML do strumienia lub TextWriter; w przeciwnym razie to ustawienie jest ignorowane.

Dotyczy