String to Byte Array Conversion
-
I want to convert a string to byte array as follows
byte[] b = Convert.FromBase64String(s);
it is giving the following error: Invalid length for a Base-64 char array. can any one give me a suggestion to solve this.Best Regards, M. J. Jaya Chitra
-
I want to convert a string to byte array as follows
byte[] b = Convert.FromBase64String(s);
it is giving the following error: Invalid length for a Base-64 char array. can any one give me a suggestion to solve this.Best Regards, M. J. Jaya Chitra
For Conversion of String to Byte Array go like this, public static byte[] StrToByteArray(string str) { System.Text.ASCIIEncoding encoding=new System.Text.ASCIIEncoding(); return encoding.GetBytes(str); } Don't go with Base 64 because it is of invalid length. Because of an unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Regards, Satips.:rose:
-
I want to convert a string to byte array as follows
byte[] b = Convert.FromBase64String(s);
it is giving the following error: Invalid length for a Base-64 char array. can any one give me a suggestion to solve this.Best Regards, M. J. Jaya Chitra
-
For Conversion of String to Byte Array go like this, public static byte[] StrToByteArray(string str) { System.Text.ASCIIEncoding encoding=new System.Text.ASCIIEncoding(); return encoding.GetBytes(str); } Don't go with Base 64 because it is of invalid length. Because of an unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Regards, Satips.:rose:
Thank you, Thanks a lot.
Best Regards, M. J. Jaya Chitra
-
For Conversion of String to Byte Array go like this, public static byte[] StrToByteArray(string str) { System.Text.ASCIIEncoding encoding=new System.Text.ASCIIEncoding(); return encoding.GetBytes(str); } Don't go with Base 64 because it is of invalid length. Because of an unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Regards, Satips.:rose:
Satips wrote:
For Conversion of String to Byte Array go like this, public static byte[] StrToByteArray(string str) { System.Text.ASCIIEncoding encoding=new System.Text.ASCIIEncoding(); return encoding.GetBytes(str); }
Or simply:
byte[] data = System.Text.Encoding.ASCII.GetBytes(str);
--- single minded; short sighted; long gone;
-
Thank you, Thanks a lot.
Best Regards, M. J. Jaya Chitra
Welcome :)
Regards, Satips.:rose:
-
Satips wrote:
For Conversion of String to Byte Array go like this, public static byte[] StrToByteArray(string str) { System.Text.ASCIIEncoding encoding=new System.Text.ASCIIEncoding(); return encoding.GetBytes(str); }
Or simply:
byte[] data = System.Text.Encoding.ASCII.GetBytes(str);
--- single minded; short sighted; long gone;
Yes Guffa. But if i give it Like that Jaya will ask how ? so i typed it as so simple format so that she can easily understand the concept.
Regards, Satips.:rose: