Class StreamWriter
Represents a writer that can write a sequential series of characters.
public class StreamWriter : TextWriter
- Inheritance
-
objectMarshalByRefObjectTextWriterStreamWriter
- Extension Methods
Properties
BaseStream
Gets the underlying stream that interfaces with a backing store.
public Stream BaseStream { get; }
Property Value
- Stream
Encoding
Returns current stream writer encoding.
public override Encoding Encoding { get; }
Property Value
- Encoding
Methods
Dispose(bool)
Releases all resources.
protected override void Dispose(bool disposing)
Parameters
disposingboolDisposing
Flush()
Clears all buffers for the current writer and causes any buffered data to be written to the underlying stream.
public override void Flush()
New(Stream)
Returns new instance of stream writer class.
public static StreamWriter New(Stream stream)
Parameters
streamStreamStream object
Returns
New(Stream, Encoding)
Returns new instance of stream writer class.
public static StreamWriter New(Stream stream, Encoding encoding)
Parameters
streamStreamStream object
encodingEncodingEncoding
Returns
New(StreamWriter)
Returns new instance of stream writer class.
public static StreamWriter New(StreamWriter sw)
Parameters
swStreamWriterStream writer object
Returns
New(string)
Returns new instance of stream writer class.
public static StreamWriter New(string path)
Parameters
pathstringPath to file
Returns
New(string, bool)
Returns new instance of stream writer class.
public static StreamWriter New(string path, bool append)
Parameters
pathstringPath to file
appendboolIf should append data to existing file
Returns
New(string, bool, Encoding)
Returns new instance of stream writer class.
public static StreamWriter New(string path, bool append, Encoding encoding)
Parameters
pathstringPath to file
appendboolIf should append data to existing file
encodingEncodingEncoding
Returns
Write(char)
Writes one character to stream.
public override void Write(char value)
Parameters
valuecharValue to write
Write(char[], int, int)
Writes char array to the stream.
public override void Write(char[] buffer, int index, int count)
Parameters
bufferchar[]Buffer with chars
indexintBuffer start index
countintNumber of characters to write
Write(string)
Writes a string to the stream.
public override void Write(string value)
Parameters
valuestringString to write
WriteLine(string)
Writes a string followed by a line terminator to the text stream.
public override void WriteLine(string value)
Parameters
valuestringValue to write