Reads a sequence of bytes from the current
PgSqlBlob stream and advances the position within the stream by the number of bytes read.
Parameters
- buffer
- The byte array buffer to be populated.
- offset
- The zero-based byte offset in the buffer.
- count
- The amount of bytes to read.
Return Value
The total number of bytes read into the buffer.
In the example below a
PgSqlBlob is created with 10 bytes in it. Then
Position is changed using
Seek method. An attempt to read 10 bytes is made afterwards, however, only 5 bytes remain till the end of the stream, so TargetArray is populated with 5 bytes only.
public void ReadFromMyBlob()
{
byte[] myByteArray = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
byte[] TargetArray = new Byte[15];
PgSqlBlob myBlob = new PgSqlBlob(myByteArray);
myBlob.Seek(5, SeekOrigin.Begin);
Console.WriteLine(myBlob.Read(TargetArray, 0, 10) + " bytes are read");
}
Public Sub ReadFromMyBlob()
Dim myByteArray() As Byte = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
Dim TargetArray(15) As Byte
Dim myBlob As PgSqlBlob = New PgSqlBlob(myByteArray)
myBlob.Seek(5, SeekOrigin.Begin)
Console.WriteLine(String.Concat(myBlob.Read(TargetArray, 0, 10), " bytes are read"))
End Sub
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2