Initializes a new MemoryStream based on the specified region of a byte array with the CanWrite property set as specified.
[Visual Basic] Overloads Public Sub New( _ ByVal buffer() As Byte, _ ByVal index As Integer, _ ByVal count As Integer, _ ByVal writeable As Boolean, _ ByVal publicallyVisible As Boolean _ ) [C#] public MemoryStream( byte[] buffer, int index, int count, bool writeable, bool publicallyVisible ); [C++] public: MemoryStream( unsigned char* buffer[], int index, int count, bool writeable, bool publicallyVisible ); [JScript] public function MemoryStream( buffer : Byte[], index : int, count : int, writeable : Boolean, publicallyVisible : Boolean );
Exception Type | Condition |
---|---|
ArgumentNullException | buffer is null. |
ArgumentOutOfRangeException | index or count is negative. |
ArgumentException | The buffer length minus index is less than count. |
AccessException | publicallyVisible is false. |
The CanRead and CanSeek properties are both set to true. This constructor can call GetBuffer.
The length of the stream cannot be set to a value greater than the initial length of the specified byte array; however, the stream can be truncated (see SetLength).
MemoryStream Class | MemoryStream Members | System.IO Namespace | MemoryStream Constructor Overload List