Invalid length for a Base-64 char array.
First of all check your string length whenever you face this error.
It came when you use to convert string into byte using Convert.FromBase64String.
This method takes the array of char from your
string. If char length < 64 then it will throw the above exception.
You must need to check
the char length before calling this.
You can create this
exception like:
// is OK
Byte[] bt1=Convert.FromBase64String("ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL");
// will throw Exception
Byte[] bt2 = Convert.FromBase64String("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
It will ignore the space
// will also throw Exception because of
Space
Byte[] bt2 = Convert.FromBase64String("ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJ");
No comments:
Post a Comment