다음을 통해 공유


XmlTextWriter.Flush 메서드

정의

버퍼에 있는 모든 내용을 내부 스트림으로 플러시하고 내부 스트림도 플러시합니다.

public:
 override void Flush();
public override void Flush ();
override this.Flush : unit -> unit
Public Overrides Sub Flush ()

예제

다음 예제에서는 두 개의 XML 조각을 작성합니다.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   XmlTextWriter^ writer = gcnew 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();
}
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

설명

참고

.NET Framework 2.0부터 메서드와 XmlWriterSettings 클래스를 사용하여 XmlWriter.Create 인스턴스를 만들어 XmlWriter 새 기능을 활용하는 것이 좋습니다.

버퍼에 Close 있는 항목을 잃지 않고 기본 스트림에 더 많이 쓰려는 경우 대신 호출됩니다.

적용 대상