Using Embedded Resources - .Net Framework

Here are the steps to using a file as an embedded resource.

  1. Include the file in your project
  2. In the Properties Window, set the Build Action property to Embedded Resource.
  3. To use the embedded resource in code, use the following example. You can convert code between C# and VB.NET at this website.

Image

namespace Maestro.SongUi
{
    internal class Common
    {
        public static Cursor GetLineSelectionCursor()
        {
            Cursor result = null;
            /*                     v-- Namespace
             *                     v              v-- folder name
             */                    v              v         v-- file name --v
            string resourceName = "Maestro.SongUi.Resources.SelectTextLine.cur";
            Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);

            if (s != null)
                result = new Cursor(s);

            return result;
        }
    }
}