Skip to content
CShift0.32

StreamReader

Struct · namespace System · Since 0.19

struct StreamReader : IDisposable

Reads a UTF-8 text file line by line (or all of it).

Name Description
Open Opens a UTF-8 text file for reading; a byte order mark at its start is skipped.
static IoError<StreamReader> Open(StringSlice path)

Opens a UTF-8 text file for reading; a byte order mark at its start is skipped.

Errors

Name Description
EndOfStream Whether the end of the file is reached.
ReadLine The next line, without its line break (\n or \r\n): while (reader.ReadLine() is string line) ....
ReadToEnd The rest of the file.
Close Closes the file.
Dispose Closes the file (StreamReader.Close); using calls it.
bool EndOfStream()

Whether the end of the file is reached.

Optional<string> ReadLine()

The next line, without its line break (\n or \r\n): while (reader.ReadLine() is string line) ....

Returns nothing (null) at the end of the file.

string ReadToEnd()

The rest of the file. Bytes that are not valid UTF-8 become ?.

void Close()

Closes the file.

void Dispose()

Closes the file (StreamReader.Close); using calls it.