Method ReadAllBytes
ReadAllBytes(Stream)
Performs a 'naive' read of the stream from it's current position to it's end and returns a byte array with the contents.
Declaration
public static byte[] ReadAllBytes(this Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream. |
Returns
Type | Description |
---|---|
System.Byte[] | A byte array containing the stream contents. |
Remarks
This method should only be used on streams known to be small, as it reads all data in one go into a byte array in memory. Performing this on streams with large content, or where the stream length is unknown will cause problems.
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if |