다음을 통해 공유


StreamWriter.AutoFlush 속성

StreamWriterStreamWriter.Write를 호출할 때마다 해당 버퍼를 내부 스트림에 플러시할지 여부를 나타내는 값을 가져오거나 설정합니다.

네임스페이스: System.IO
어셈블리: mscorlib(mscorlib.dll)

구문

‘선언
Public Overridable Property AutoFlush As Boolean
‘사용 방법
Dim instance As StreamWriter
Dim value As Boolean

value = instance.AutoFlush

instance.AutoFlush = value
public virtual bool AutoFlush { get; set; }
public:
virtual property bool AutoFlush {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_AutoFlush ()

/** @property */
public void set_AutoFlush (boolean value)
public function get AutoFlush () : boolean

public function set AutoFlush (value : boolean)

속성 값

StreamWriter가 해당 버퍼를 플러시하게 하려면 true이고, 그렇지 않으면 false입니다.

설명

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

AutoFlushfalse로 설정될 때 StreamWriter는 전달된 인코딩의 인코더에서 내부적으로 뿐만 아니라 잠재적으로 제한된 버퍼링을 수행합니다. AutoFlushfalse로 설정하여 더 나은 성능을 가져올 수 있으며 StreamWriter로 쓰기를 수행할 때 Close(또는 적어도 Flush)가 항상 호출된다고 가정됩니다.

예를 들어, 사용자가 즉각적인 피드백이 예상되는 장치에 쓸 때 AutoFlushtrue로 설정합니다. Console.Out이 이러한 경우 중 하나입니다. Console에 쓰는 데 내부적으로 사용된 StreamWriterStreamWriter.Write를 호출할 때마다 해당 내부 상태를 모두 플러시합니다.

이 속성을 사용하는 방법에 대한 예제를 보려면 아래 예제 단원을 참조하십시오. 다음 표에서는 일반적인 예 또는 관련된 I/O 작업의 예를 보여 줍니다.

수행 작업

참조 항목

텍스트 파일을 만듭니다.

방법: 파일에 텍스트 쓰기

텍스트 파일에 씁니다.

방법: 파일에 텍스트 쓰기

텍스트 파일에서 읽습니다.

방법: 파일의 텍스트 읽기

예제

다음 예제에서는 AutoFlush 속성을 사용하는 구문을 보여 줍니다.

' Gets or sets a value indicating whether the StreamWriter
' will flush its buffer to the underlying stream after every 
' call to StreamWriter.Write.
Sw.AutoFlush = True
// Gets or sets a value indicating whether the StreamWriter
// will flush its buffer to the underlying stream after every 
// call to StreamWriter.Write.
sw.AutoFlush = true;                             
// Gets or sets a value indicating whether the StreamWriter
// will flush its buffer to the underlying stream after every 
// call to StreamWriter.Write.
sw->AutoFlush = true;
// Gets or sets a value indicating whether the StreamWriter
// will flush its buffer to the underlying stream after every 
// call to StreamWriter.Write.
sw.set_AutoFlush(true);

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

StreamWriter 클래스
StreamWriter 멤버
System.IO 네임스페이스

기타 리소스

파일 및 스트림 I/O
방법: 파일의 텍스트 읽기
방법: 파일에 텍스트 쓰기