public object GetImage(string path)
{
FileStream fs=new FileStream(path,FileMode.Open);
try
{
Image img =Image.FromStream(fs);
return img;
}
catch(Exception ex)
{
throw ex;
}
finally
{
fs.Close();
}
}
这种方法读取图片之后就释放掉资源。比较安全,不会报错。