StreamReader
Struct · namespace System · Since 0.19
struct StreamReader : IDisposableReads a UTF-8 text file line by line (or all of it).
Static methods
Section titled “Static methods”| 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
IoError.CannotOpen: the file does not exist or cannot be read.
Methods
Section titled “Methods”| 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. |
EndOfStream
Section titled “EndOfStream”bool EndOfStream()Whether the end of the file is reached.
ReadLine
Section titled “ReadLine”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.
ReadToEnd
Section titled “ReadToEnd”string ReadToEnd()The rest of the file. Bytes that are not valid UTF-8 become ?.
void Close()Closes the file.
Dispose
Section titled “Dispose”void Dispose()Closes the file (StreamReader.Close); using calls it.