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

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s