StreamWriter
Struct · namespace System · Since 0.19
struct StreamWriter : IDisposableWrites text to a file as UTF-8.
Static methods
Section titled “Static methods”| Name | Description |
|---|---|
Create |
Creates a new, empty text file (an existing one is truncated). |
Append |
Opens a text file for writing at its end; it is created if it does not exist. |
Create
Section titled “Create”static IoError<StreamWriter> Create(StringSlice path)Creates a new, empty text file (an existing one is truncated).
Errors
IoError.CannotCreate: the file cannot be created (a missing folder, no permission).
Append
Section titled “Append”static IoError<StreamWriter> Append(StringSlice path)Opens a text file for writing at its end; it is created if it does not exist.
Errors
IoError.CannotCreate: the file cannot be opened or created.
Methods
Section titled “Methods”| Name | Description |
|---|---|
Write |
Writes text. |
WriteLine |
Writes text and a line break (\n). |
Flush |
Writes what is still buffered to the file. |
Close |
Closes the file. |
Dispose |
Closes the file (StreamWriter.Close); using calls it. |
IoError<void> Write(StringSlice text)Writes text.
Errors
IoError.CannotWrite: writing failed.
WriteLine
Section titled “WriteLine”IoError<void> WriteLine(StringSlice text)Writes text and a line break (\n).
Errors
IoError.CannotWrite: writing failed.
IoError<void> WriteLine()Writes a line break (\n).
Errors
IoError.CannotWrite: writing failed.
void Flush()Writes what is still buffered to the file.
void Close()Closes the file.
Dispose
Section titled “Dispose”void Dispose()Closes the file (StreamWriter.Close); using calls it.