XmlTextWriter.Flush Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Lava o que está no buffer para os fluxos subjacentes e também lava o jato subjacente.
public:
override void Flush();
public override void Flush();
override this.Flush : unit -> unit
Public Overrides Sub Flush ()
Exemplos
O exemplo seguinte escreve dois fragmentos XML.
using System;
using System.IO;
using System.Xml;
public class Sample
{
public static void Main()
{
XmlTextWriter writer = new XmlTextWriter (Console.Out);
//Use indenting for readability
writer.Formatting = Formatting.Indented;
//Write an XML fragment.
writer.WriteStartElement("book");
writer.WriteElementString("title", "Pride And Prejudice");
writer.WriteEndElement();
writer.Flush();
//Write another XML fragment.
writer.WriteStartElement("cd");
writer.WriteElementString("title", "Americana");
writer.WriteEndElement();
writer.Flush();
//Close the writer.
writer.Close();
}
}
Imports System.IO
Imports System.Xml
public class Sample
public shared sub Main()
Dim writer as XmlTextWriter = new XmlTextWriter (Console.Out)
'Use indenting for readability
writer.Formatting = Formatting.Indented
'Write an XML fragment.
writer.WriteStartElement("book")
writer.WriteElementString("title", "Pride And Prejudice")
writer.WriteEndElement()
writer.Flush()
'Write another XML fragment.
writer.WriteStartElement("cd")
writer.WriteElementString("title", "Americana")
writer.WriteEndElement()
writer.Flush()
'Close the writer.
writer.Close()
end sub
end class
Observações
Note
Recomendamos que crie instâncias XmlWriter usando o método XmlWriter.Create e a classe XmlWriterSettings para aproveitar a nova funcionalidade.
Isto é chamado em vez de Close quando queres escrever mais no stream subjacente sem perder o que ainda está no buffer.