C# Tutorials : Convert an Image from Base64 and to Base64 Images Converter

C# tutorials for beginner : how to create Base64 Images Converter windows applications? Convert from base64 and from base64 to an images using C# programming language.

C# for beginners - How to convert an image to Base64 code and/or from Base64 code into an image using C# programming language? The simple application 'Images Converter' will allow you to convert all images type to Base64 codes, we can select / browse an image where we want to convert it, just click "Convert button" and you get your Base64 code.

Please read :
  1. Create Simple Random Password Generator
  2. CRUD Operations Insert,Update,Delete with MySQL Database
 After image already converted, you can fill it into a PictureBox, then we can create copy or paste button to copy or paste all base64 code from teh RichTexBox.

Create Base64 Images Converter

Just create new project in your visual studio and rename with "Base64ImagesConverter", at the form1.vb please add 6 Buttons, one TextBox, One RichTextBox and OpenFileDialog Component, and design it look like this images :

Convert an Image from Base64 and to Base64

Just focuss to our project dude xD

Source Code Base64 Images Convert (Form1.Cs)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Base64ImagesConverter {
    public partial class Form1 : Form {
        public Form1() {
        private void button1_Click(object sender, EventArgs e) {
            DialogResult dr = openFileDialog1.ShowDialog();
            try {

                textBox1.Text = openFileDialog1.FileName;

            } catch (Exception x) {

        private void button2_Click(object sender, EventArgs e) {

            if (textBox1.Text == "") {

                MessageBox.Show("No path spesified");
            else {

                byte[] imagearray = System.IO.File.ReadAllBytes(textBox1.Text);
                string createBase64 = Convert.ToBase64String(imagearray);
                richTextBox1.Text = createBase64;
        private void button3_Click(object sender, EventArgs e) {

            if (richTextBox1.Text !="") {

                // we can create base64 functions
                pictureBox1.Image = Base64toImage(richTextBox1.Text);

            } else {

                MessageBox.Show("Paste Base 64 string First");
        public Image Base64toImage(string base64string) {

            // Convert Base64 String to byte[]
            byte[] imagesByte = Convert.FromBase64String(base64string);
            System.IO.MemoryStream ms = new System.IO.MemoryStream(imagesByte, 0 , imagesByte.Length);

            // Convert byte[] to Image , based on @Crulex comment, the below line has no need since MemoryStream already initialized
            ms.Write(imagesByte, 0 , imagesByte.Length);
            Image image = Image.FromStream(ms, true);
            return image;
        private void button4_Click(object sender, EventArgs e) {

            MessageBox.Show("Copied to clipboard!");
        private void button5_Click(object sender, EventArgs e) {
            richTextBox1.Text = Clipboard.GetText();
        private void button6_Click(object sender, EventArgs e) {

If you're still confused, please watch video tutorials below,

Video tutorials How to Convert Image from / to Base64 code

Download full source code https://www.dropbox.com/s/ruhzif4eiyu9tsc/hc-kr-com-Base64ImagesConverter.zip?dl=0


Feel free to code it up and send us a pull request.

Hi everyone, let's me know how much this lesson can help your work. Please Subscribe and Follow Our Social Media 'kodeajaib[dot]com' to get Latest tutorials and will be send to your email everyday for free!, Just hit a comment if you have confused. Nice to meet you and Happy coding :) all ^^

Follow by E-Mail


ADO.NET,3,Ajax,6,Android,9,AngularJS,4,ASP.NET,4,Blogger Tutorials,7,Bootstrap,7,C++,1,Codeigniter,2,Cplusplus,6,Crystal Report,6,CSharp,25,Ebook Java,2,FlyExam,1,FSharp,3,Game Development,2,Java,35,JDBC,2,Laravel,84,Lumen,2,MariaDB,2,Ms Access,3,MySQL,31,ODBC,6,OleDB,1,PHP,14,PHP Framework,5,PHP MYSQLI,9,PHP OOP,5,Python,8,Python 3,4,SQL Server,4,SQLite,4,Uncategorized,5,Vb 6,2,Vb.Net,89,Video,48,Vue Js,4,WPF,2,Yii,3,
KODE AJAIB: C# Tutorials : Convert an Image from Base64 and to Base64 Images Converter
C# Tutorials : Convert an Image from Base64 and to Base64 Images Converter
C# tutorials for beginner : how to create Base64 Images Converter windows applications? Convert from base64 and from base64 to an images using C# programming language.
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy