How to display Base64 images in HTML with c#
If you need convert image to Data URL (embedding Image) here the code:
Encode to Base64 format
public static string GetDataURL(string imgFile)
{
return "<img src=\"data:image/"
+ Path.GetExtension(imgFile).Replace(".","")
+ ";base64,"
+ Convert.ToBase64String(File.ReadAllBytes(imgFile)) + "\" />";
}
Commentaires
Enregistrer un commentaire