hashi hashi - 1 year ago 151
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 Source
        public static string GetDataURL(string imgFile)
            return "<img src=\"data:image/" 
                        + Path.GetExtension(imgFile).Replace(".","")
                        + ";base64," 
                        + Convert.ToBase64String(File.ReadAllBytes(imgFile)) + "\" />";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download