dotConnect for MySQL Documentation
Devart.Data.MySql Namespace / MySqlBlob Class / CanWrite Property
Example

In This Topic
    CanWrite Property
    In This Topic
    Gets a value indicating whether the MySqlBlob object supports writing.
    Syntax
    'Declaration
     
    Public Overrides ReadOnly Property CanWrite As Boolean
    public override bool CanWrite {get;}

    Property Value

    true if the MySqlBlob stream can be written; false if a MySqlBlob is closed, disposed or Null.
    Remarks
    Use this property to determine whether you can write to the instance of MySqlBlob class.
    Example
    void ReverseBlob()
    {
      byte[] byteArray = { (byte)'A', (byte)'B', (byte)'C' };
      MySqlBlob blobFrom = new MySqlBlob(byteArray);
      //blobFrom.ToString() = "ABC"
    
      MySqlBlob blobTo = new MySqlBlob();
      ........
      //reverse MySqlBlob
      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 MySqlBlob(byteArray)
      ' blobFrom.ToString() = "ABC"
    
      Dim blobTo As New MySqlBlob
      ......
      ' reverse MySqlBlob
      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