Deleting an image which is opened in picturebox:
private void button1_Click_1(object sender, EventArgs e)
{
lblimgname.Text = "Right Thumb 1";
string savepath = @"C:/BrainScript/" + clientname + "/";
FileStream fs = new FileStream(savepath + clientname + "_" + lblimgname.Text + ".jpg", FileMode.Open, FileAccess.Read);
Image img = Image.FromStream(fs);
fs.Close();
picRightthumb1.Image = img.Clone() as Image;
img.Dispose();
File.Delete(savepath + clientname + "_" + lblimgname.Text + ".jpg");
}
private Image GetCopyImage(string path)
{
using (Image im = Image.FromFile(path))
{
Bitmap bm = new Bitmap(im);
return bm;
}
}
I have written the above code to delete the image which is opened in the picturebox but i am getting error "The process is used by another process" pls help me out from this problem.