Showing posts with label Resource. Show all posts
Showing posts with label Resource. Show all posts

Tuesday, July 19, 2016

어셈블리 리소스에서 이미지 읽기 (Load image from assembly resource)

using System.Reflection;
using System.Resources;

public static object LoadProjectResource(string strResName)
{
      Assembly assembly = Assembly.GetExecutingAssembly();
      string strBaseName = assembly.GetName().Name + "." + "Properties.Resources";
      ResourceManager rm = new ResourceManager(strBaseName, assembly);
      return rm.GetObject(strResName);
}

// 사용방법  hello 라는 이미지가 프로그램(어셈블리)리소스에 있다면
Image1.Image = LoadProjectResource("hello");