dotConnect for SQLite Documentation
Devart.Data.SQLite Namespace / SQLiteBlob Class / CanSeek Property
Example

In This Topic
    CanSeek Property
    In This Topic
    Gets a value indicating whether forward and backward seek operations can be performed.
    Syntax
    'Declaration
     
    Public Overrides ReadOnly Property CanSeek As Boolean
    public override bool CanSeek {get;}

    Property Value

    true if the SQLiteBlob stream supports seeking; false if a SQLiteBlob is closed, disposed, or Null.
    Remarks
    Use this property to find out if a SQLiteBlob supports Seek operation. SQLiteBlob does not support seeking if it has Null value as well as if it has been disposed or closed.
    Example
    void ReverseBlob()
    {
      byte[] byteArray = { (byte)'A', (byte)'B', (byte)'C' };
      SQLiteBlob blobFrom = new SQLiteBlob(byteArray);
      //blobFrom.ToString() = "ABC"
    
      SQLiteBlob blobTo = new SQLiteBlob();
      ........
      //reverse SQLiteBlob
      if (blobFrom.CanSeek && blobFrom.CanRead && blobTo.CanWrite)
        for (blobFrom.Seek(-1, System.IO.SeekOrigin.End); ;blobFrom.Position -= 2)
        {
          blobTo.WriteByte((byte)blobFrom.ReadByte());
          if (blobFrom.Position == 1) break;
        }
      //blobTo.ToString() = "CBA";
    }
    Private Sub ReverseBlob()
      Dim byteArray As Byte() = New Byte() {AscW("A"c), AscW("B"c), AscW("C"c)}
      Dim blobFrom As New SQLiteBlob(byteArray)
      ' blobFrom.ToString() = "ABC"
    
      Dim blobTo As New SQLiteBlob
      ......
      ' reverse SQLiteBlob
      If ((blobFrom.CanSeek AndAlso blobFrom.CanRead) AndAlso blobTo.CanWrite) Then
        blobFrom.Seek(CLng(-1), System.IO.SeekOrigin.End)
        Do While True
          blobTo.WriteByte(CByte(blobFrom.ReadByte))
          If (blobFrom.Position = 1) Then
            Return
          End If
          blobFrom.Position = blobFrom.Position - 2
        Loop
      End If
      ' blobTo.ToString() = "CBA";
    End Sub
    Requirements

    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

    See Also