have you thought in do it with resources?
To get from resources:
MainNameSpace.Properties.Resources.NameOfIconFileInResources;
Put the icons in resources, if you have the image file (not icon) i have a method to change it:
public static Icon toIcon(Bitmap b)
{
Bitmap cb = (Bitmap) b.Clone();
cb.MakeTransparent(Color.White);
System.IntPtr p = cb.GetHicon();
Icon ico = Icon.FromHandle(p);
return ico;
}
And programmatically change it with the known attribute .Icon;
Don't worry about ImageSource type.
Extracting image from icon (.ico) file:
Stream iconStream = new FileStream (MainNameSpace.Properties.Resources.NameOfIconFileINResources, FileMode.Open );
IconBitmapDecoder decoder = new IconBitmapDecoder (
iconStream,
BitmapCreateOptions.PreservePixelFormat,
BitmapCacheOption.None );
// loop through images inside the file
foreach ( var item in decoder.Frames )
{
//Do whatever you want to do with the single images inside the file
this.panel.Children.Add ( new Image () { Source = item } );
}
// or just get exactly the 4th image:
var frame = decoder.Frames[3];
// save file as PNG
BitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(frame);
using ( Stream saveStream = new FileStream ( @"C:\target.png", FileMode.Create ))
{
encoder.Save( saveStream );
}
But you must put the .ico file in resources, or take it with relative path...
Taken from How can you access icons from a Multi-Icon (.ico) file using index in C#