Invalid length for a Base-64 char array

If you get this error when you are trying to decode a base64 encoded string do the following to fix the length problem:

int m = str64.Length % 4;
if ( m > 0 )
    str64 += new string( '=', 4 - m );
Categories: C# Tags: , , , ,
%d bloggers like this: