C#下读取Resource的png图片并放入imagelist中

string address_temp = AppDomain.CurrentDomain.BaseDirectory ;
string address = address_temp.Substring(0,address_temp.Length - 11);
string[] image1 = Directory.GetFiles(address+@"\Resources", "*.png");

ImageList image = new ImageList(); ;
List<string> st=new List<string>();
System.Resources.ResourceManager rm= YQJDESIGN.Properties.Resources.ResourceManager;
int i=0;
foreach (var mp in image1)
{
//string temp_st;

st.Add (mp.Replace(address+"\\Resources\\", "").Replace(".png",""));
Image obj = (System.Drawing.Image)rm.GetObject(st[i], YQJDESIGN.Properties.Resources.Culture);
image.Images.Add(obj);
i++;
}

posted @ 2013-05-21 17:40  江南小驴  阅读(2885)  评论(0编辑  收藏  举报