I have a problem when I try to delete an image file. I always get an error: IOExeption was unhandled. Acces denied because the file is used for another process.
I do not know what process could be and how to solve it.
private void comboBox3_SelectedIndexChanged (object sender, EventArgs e)
{
Album album = GetAlbum (comboBox1.SelectedIndex);
Photo photo = GetPhoto (comboBox1.SelectedIndex, comboBox3.SelectedIndex);
txtPhotoPath.Text = Directory.GetCurrentDirectory () + "\\" + photo.SPath;
lblExtention.Text = photo.SExtention;
txtPhotoTitle.Text = photo.STitle;
pctrbFoto.Image = Image.FromFile (foto.SPath) .GetThumbnailImage (GetWitdth (photo.SPath, GetHeight (photo.SPath, 150)), GetfHeight (photo.SPath, 150), null, new IntPtr ());
}
private void btnChangePhoto_Click (object sender, EventArgs e)
{
Album album = GetAlbum (comboBox1.SelectedIndex);
Photo photo = GetPhoto (comboBox1.SelectedIndex, comboBox3.SelectedIndex);
File.Delete ("Albums \\ Images \\" + photo.STitle + foto.SExtention);
photo.SExtention = lblExtention.Text;
photo.STitle = txtPhotoTitel.Text;
Photo.SPath = txtPath.Text;
File.Copy (photo.SPath, "Albums \\ Images \\" + photo.STitle + photo.SExtention);
}Thanks Vinzcent
Thank you all for your help.
I used this and it works fine now
- , , null, - :
var img = .FromFile(foto.SPath).GetThumbnailImage(GetWitdth ( .SPath,
GetHeight ( .SPath, 150)), GetfHeight (photo.SPath, 150), null, IntPtr());
pctrbFoto.Image = img;
img = null;
GC.Collect();