Tuesday, 9 June 2015

Convert ByteArray to Base64 String and Base 64 String to ByteArray

Today when I was working on some images reading and updating to some other systems, I need to write a code for converting Byte Array to Base 64 and Vice Versa.
  public static void ConvertByteArrayToBase64()
       byte[] byteArray = File.ReadAllBytes(@"Image.png");
       string strBase64 = Convert.ToBase64String(byteArray);

  public static void ConvertBase64ToByteArray(string strBase64)
       byte[] byteArray = Convert.FromBase64String(strBase64);

Hope this helps.

Happy CRM'img

No comments:

Post a Comment