ReadToEnd Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Reads all characters from the current position to the end of the stream.

Namespace:  System.IO
Assembly:  System.IO (in System.IO.dll)

public override string ReadToEnd()

Return Value

Type: System..::..String
The rest of the stream as a string, from the current position to the end. If the current position is at the end of the stream, returns an empty string ("").

ReadToEnd works best when you need to read all the input from the current position to the end of the stream. If more control is needed over how many characters are read from the stream, use the Read(array<Char>[]()[][], Int32, Int32) method overload, which generally results in better performance.

ReadToEnd assumes that the stream knows when it has reached an end. For interactive protocols in which the server sends data only when you ask for it and does not close the connection, ReadToEnd might block indefinitely because it does not reach an end, and should be avoided.

Note that when using the Read method, it is more efficient to use a buffer that is the same size as the internal buffer of the stream. If the size of the buffer was unspecified when the stream was constructed, its default size is 4 kilobytes (4096 bytes).

Show: