public void UpdateImg(string picpath)
{
//更新至控件中
PnlImageShow.BackgroundImage = LoadImgPath(picpath);
}
//读取PNG文件,生成Image对象
Image LoadImgPath(string picpath)
{
//默认资源文件
System.Drawing.Image bmp = Resources.defaultpic;
//判断文件是否存在
if (File.Exists(picpath))
{
FileStream image = new FileStream(
picpath,
FileMode.Open,
System.IO.FileAccess.Read,
FileShare.ReadWrite
);
bmp = Image.FromStream(image);
image.Close();
}
return bmp;
}