IsolatedStorageFileStream.Read Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Copies bytes from the current buffered IsolatedStorageFileStream object to an array.

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

Syntax

'Declaration
Public Overrides Function Read ( _
    buffer As Byte(), _
    offset As Integer, _
    count As Integer _
) As Integer
public override int Read(
    byte[] buffer,
    int offset,
    int count
)

Parameters

  • offset
    Type: System.Int32
    The offset in the buffer at which to begin writing.
  • count
    Type: System.Int32
    The maximum number of bytes to read.

Return Value

Type: System.Int32
The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero if the end of the stream is reached.

Exceptions

Exception Condition
IsolatedStorageException

The isolated store has been removed.

-or-

Isolated storage is disabled.

ArgumentException

offset and count describe an invalid range in buffer.

ArgumentNullException

buffer is nulla null reference (Nothing in Visual Basic).

ArgumentOutOfRangeException

offset or count is negative.

IOException

The stream is closed or an internal error has occurred.

ObjectDisposedException

The stream has been disposed.

Remarks

The buffer parameter can be an instance of the Buffer class, or an array of one of the following types: Byte, SByte, Char, Int16, Int32, Int64, UInt16, UInt32, UInt64, Single, or Double. The offset parameter gives the offset of the byte in buffer at which to begin writing (index in the buffer), and the count parameter gives the maximum number of bytes that will be read from this stream. The returned value is the actual number of bytes read, or zero if the end of the stream is reached. If the read operation is successful, the current position of the stream is advanced by the number of bytes read. If an exception occurs, the current position of the stream is unchanged.

The Read method treats the buffer parameter as a block of bytes, regardless of its actual type. Likewise, the offset and count parameters are always specified in bytes. For buffer parameters other than byte arrays, this means that an element index must be multiplied by the element size in bytes to form a correct value for offset or count.

The Read method will return zero only if the end of the stream is reached. In all other cases, Read always reads at least one byte from the stream before returning. If no data is available from the IsolatedStorageFileStream object upon a call to Read, the method will block until at least one byte of data can be returned.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.