I have one image displayed in picture box control in my application. Now I want to update that Image when my application is running and image already has been used by the application.
I used this line of code to update my logo image:UPDATED CODE
public void showRow()
{
string _fileName = Application.StartupPath + "\\Logo" + ".png";
using (var stream = new FileStream(_fileName, FileMode.Open, FileAccess.Read))
{
var img = Image.FromStream(stream);
pbStoreLogo.Image = img;
}
}
private void btnsave_Click(object sender, EventArgs e)
{
using (var m = new MemoryStream())
{
pbStoreLogo.Image.Save(m,System.Drawing.Imaging.ImageFormat.Png);
var img = Image.FromStream(m);
img.Save(Application.StartupPath + "\\Logo" + ".png");
}
}
And it through exception: A generic error occurred in GDI+.
So please suggest me how to change my image at run time or provide me solution of this exception.