Creates a
StreamWriter
for the specified stream. The
biggest difference between this and creating a StreamWriter
directly is that the new StreamWriter
will default to
leaving the underlying stream open on disposal. Remember to flush the
returned writer after all data have been written.
- Namespace
- Statiq
.Common - Containing Type
- StreamExtensions
Syntax
public static StreamWriter GetWriter(this Stream stream, bool leaveOpen = true)
Parameters
Name | Type | Description |
---|---|---|
stream | Stream | The stream to write to. |
leaveOpen | bool | true to leave the underlying stream open on disposal. |
Return Value
Type | Description |
---|---|
StreamWriter | A new StreamWriter for the specified stream. |