通过下面的方法就不会了。
private Image geticonimage(string name)
{
Icon icon = null;
Image image = null;
Stream stream = new MemoryStream();
try
{
object iconobj = GetImageResource(name);
if (iconobj is Icon)
{
icon = (Icon)iconobj;
icon.Save(stream);
image = Image.FromStream(stream);
}
else
{
image = (Image)iconobj;
}
}
catch
{
stream.Close();
//throw e;
image = null;
}
return image;
}
{
Icon icon = null;
Image image = null;
Stream stream = new MemoryStream();
try
{
object iconobj = GetImageResource(name);
if (iconobj is Icon)
{
icon = (Icon)iconobj;
icon.Save(stream);
image = Image.FromStream(stream);
}
else
{
image = (Image)iconobj;
}
}
catch
{
stream.Close();
//throw e;
image = null;
}
return image;
}