Error:Invalid length for a Base-64 char array occuring while using Convert.FromBase64String() RRS feed

  • Question

  • In silverlight environment, we are encoding string of data using System.Convert.ToBase64String(strPicture) as mentioned below:

    Dim strPicture as string
    Dim binaryData(strPicture.length) as Byte

    encodedString= System.Convert.ToBase64String(binaryData)

     Code that we are using for decoding is mentioned below:
    1    Dim strPicture As String
    2    Dim decodedData() As Byte
    3    Dim bytesRead As Integer
    5    decodedData = System.Convert.FromBase64String(strPicture)
    Line number 5 Causes Exception: "SystemFormatException: Invalid length for a Base-64 char array"
    Please suggest.
    Monday, November 30, 2009 1:33 AM