StringWriter.Close 메서드

정의

현재 StringWriter 및 기본 스트림을 닫습니다.

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

예제

이 코드 예제는에 대해 제공 된 큰 예제의 일부는 StringWriter(StringBuilder) 생성자입니다.

strWriter->Close();

// Since the StringWriter is closed, an exception will 
// be thrown if the Write method is called. However, 
// the StringBuilder can still manipulate the string.
strBuilder->Insert( 0, "Invalid " );
Console::WriteLine( strWriter->ToString() );
strWriter.Close();

// Since the StringWriter is closed, an exception will
// be thrown if the Write method is called. However,
// the StringBuilder can still manipulate the string.
strBuilder.Insert(0, "Invalid ");
Console.WriteLine(strWriter.ToString());
strWriter.Close()

' Since the StringWriter is closed, an exception will 
' be thrown if the Write method is called. However, 
' the StringBuilder can still manipulate the string.
strBuilder.Insert(0, "Invalid ")
Console.WriteLine(strWriter.ToString())

설명

파일을 만들고 파일에 텍스트를 쓰는 예제는 방법: 파일에 텍스트 쓰기를 참조하세요. 파일에서 텍스트를 읽는 예제는 방법: 파일에서 텍스트 읽기를 참조하세요. 이진 파일에서 읽고 쓰는 예제는 방법: 새로 만든 데이터 파일에 읽기 및 쓰기를 참조하세요.

이 메서드는 Stream.Close를 재정의합니다.

이 구현은 Close 값을 전달하는 메서드를 호출 Dispose 합니다 true .

명시적으로 를 호출 Close하지 않는 한 스트림을 플러시하면 기본 인코더가 플러시되지 않습니다. 를 로 true 설정 AutoFlush 하면 데이터가 버퍼에서 스트림으로 플러시되지만 인코더 상태는 플러시되지 않습니다. 이렇게 하면 인코더가 다음 문자 블록을 올바르게 인코딩할 수 있도록 해당 상태(부분 문자)를 유지할 수 있습니다. 이 시나리오는 인코더가 인접한 문자 또는 문자를 받은 후에만 특정 문자를 인코딩할 수 있는 UTF8 및 UTF7에 영향을 줍니다.

적용 대상

추가 정보