To C#-1 Notes

Creating a Resource File with an Image in Base-64 Format

  1. Create a C#.Net Console Application with the name CreateResx

  2. Download this image into the bin/Debug folder: happy.jpg.

  3. Replace the code in Program.cs with this code:

    using System;
    using System.Drawing;
    using System.Resources;
    namespace ResX
    {
        public class Program
        {
            public static void Main()
            {
                Image img = Image.FromFile("happy.jpg");
                ResXResourceWriter rsxw = 
                    new ResXResourceWriter("happy.resx");
                rsxw.AddResource("happy.jpg", img);
                rsxw.Close();
            }
        }
    }
    
  4. Add the references System.Drawing and System.Windows.Forms to the solution.

  5. Run the application. The file happy.resx is created in the bin/Debug folder

  6. Open happy.resx using the NotePad editor.

  7. Look at the bottom to view the base-64 representation of the happy.jpg.