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

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

What is SMART on FHIR? A Comprehensive Guide with Examples for Data Integration and Interoperability

Builder.ai's Collapse: The Hidden Dangers of Web Application Development Outsourcing