hashi hashi - 4 months ago 26
HTML Question

how to convert Image to Data URI for Html with C#?

I need convert image to Data URL (embedding Image) in the Win-application for HTML and I need
Data URL (embedding Image) to image.

Answer
        public static string GetDataURL(string imgFile)
        {
            return "<img src=\"data:image/" 
                        + Path.GetExtension(imgFile).Replace(".","")
                        + ";base64," 
                        + Convert.ToBase64String(File.ReadAllBytes(imgFile)) + "\" />";
        }