I'm making an application like a desktop. I'm trying to have a background image for the desktop, but im received an error.
Below is the button to choose a background image
private void button1_Click_2(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
if (open.ShowDialog() == DialogResult.OK)
{
Bitmap bit = new Bitmap(open.FileName);
pictureBox1.Image = bit;
pictureBox1.Image.Save(@"frame.jpeg", ImageFormat.Jpeg);
}
}
And this is how I save it when you close and reopen the app (On Form1 Void)
if (File.Exists(@"frame.jpeg"))
pictureBox1.Image = Image.FromFile(@"frame.jpeg");
else
pictureBox1.BackColor = Color.Black; //Blank
I'm getting an error on the line pictureBox1.Image.Save(@"frame_backup.jpeg", ImageFormat.Jpeg);
, where it says the image is in use.
I tried doing PictureBox1.Image = null;
to clear the image from picture but it still errors!