c# image byte array to base64 code example
Example 1: converting image to base64 C#
using (Image image = Image.FromFile(Path))
{
using (MemoryStream m = new MemoryStream())
{
image.Save(m, image.RawFormat);
byte[] imageBytes = m.ToArray();
// Convert byte[] to Base64 String
string base64String = Convert.ToBase64String(imageBytes);
return base64String;
}
}
Example 2: c# byte array to base64
public static string ToBase64String (byte[] inArray, int offset, int length, Base64FormattingOptions options);