埋め込まれたリソース取得
アイコン
// 埋め込まれたリソースを読み込む
// 引数:IconFile(プロジェクトネームスペース[.フォルダ名1.フォルダ名2・・・].アイコン名.ico)
// 例:プロジェクト内の「Icon」フォルダにある「TestIcon.ico」を埋め込まれたリソースに設定している場合
// TestProject.Icon.TestIcon.ico
private Icon LoadIcon(string IconFile)
{
// アセンブリ参照
System.Reflection.Assembly asm = System.Reflection.Assembly.GetEntryAssembly();
System.IO.Stream stream = asm.GetManifestResourceStream(IconFile);
System.IO.StreamReader reader = new System.IO.StreamReader(stream);
return new Icon(reader.BaseStream);
}
// このメソッドの使用例
System.Drawing.Icon icon = LoadIcon("TestProject.Icon.TestIcon.ico");