StreamWriter Class

Windows Automotive 5.0/5.5
Implements a TextWriter for writing characters to a stream in a particular encoding.

Namespace: System.IO
Assembly: mscorlib (in mscorlib.dll)

public class StreamWriter

StreamWriter is designed for character output in a particular Encoding, whereas classes derived from Stream are designed for byte input and output. StreamWriter defaults to using an instance of UTF8Encoding unless specified otherwise. This instance of UTF8Encoding is constructed without a Byte-Order Mark (BOM), so its GetPreamble method returns an empty byte array. To create a StreamWriter using UTF-8 encoding and a BOM, consider using a constructor that specifies encoding, such as StreamWriter(String, Boolean, Encoding). By default, a StreamWriter is not thread safe. See TextWriter.Synchronized for a thread-safe wrapper.

Available in the .NET Micro Framework versions 3.0, 4.0, 4.1, and 4.2.

Community Additions