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;

}

相关文章:

  • 2021-11-09
  • 2021-08-28
  • 2021-08-06
猜你喜欢
  • 2021-06-29
  • 2021-11-06
  • 2021-12-25
  • 2022-01-14
  • 2022-12-23
  • 2021-12-03
  • 2021-04-02
相关资源
相似解决方案