Export (0) Print
Expand All

OracleBFile.Read Method

Reads a sequence of bytes from the current OracleBFile stream and advances the position within the stream by the number of bytes read.

Namespace:  System.Data.OracleClient
Assembly:  System.Data.OracleClient (in System.Data.OracleClient.dll)

abstract Read : 
        buffer:byte[] * 
        offset:int * 
        count:int -> int  
override Read : 
        buffer:byte[] * 
        offset:int * 
        count:int -> int

Parameters

buffer
Type: System.Byte[]

An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count) replaced by the bytes read from the current source.

offset
Type: System.Int32

The zero-based byte offset in buffer at which to begin storing the data read from the current stream.

count
Type: System.Int32

The maximum number of bytes to be read from the current stream.

Return Value

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

ExceptionCondition
ArgumentException

The sum of offset and count is larger than the buffer length.

ArgumentNullException

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

ArgumentOutOfRangeException

offset or count is negative.

InvalidOperationException

The connection with which a BFILE is associated is closed.

IOException

An I/O error occurred.

ObjectDisposedException

Methods were called after the stream was closed or disposed.

The Read method read a maximum of count bytes from the current stream and store them in buffer beginning at offset. The current position within the stream is advanced by the number of bytes read; however, if an exception occurs, the current position within the stream remains unchanged. Read returns the number of bytes read. The return value is zero only if the position is currently at the end of the stream. Read will block until at least one byte of data can be read, in the event that no data is available. Read returns 0 only when the end of the file has been reached. Read is free to return fewer bytes than requested even if the end of the stream has not been reached.

Any attempt to access a closed OracleBFile using the Read or Seek methods reopens an OracleBFile stream automatically.

The following C# example assumes this schema in an Oracle table:

(col1 number, col2 BFILE)

The example demonstrates using the Read and Seek methods to access an OracleBFile object.

byte[] buffer = new byte[100];
OracleDataReader dataReader = command.ExecuteReader();
using (dataReader) {
    if (dataReader.Read()) {
            OracleBFile BFile = dataReader.GetOracleBFile(1);
        using (BFile) {
            BFile.Seek(0, SeekOrigin.Begin);
            BFile.Read(buffer, 0, 100);
        }
    }
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft