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

Posts les plus consultés de ce blog

Solution GED sur le Cloud (Gestion électronique des documents)

La Norme HL7 et son Intégration avec le Moteur Yoctobe : Guide Complet pour l'Interopérabilité en Santé

How Slack's Custom Mobile App Development Solved the £8.2 Billion Productivity Problem