I think that my problem is related with closed Topic: How can I stop <Image Source="file path"/> process?. That topic is closed and the answer for it doesn't work for me.
My problem is fact, that I can't use File.Delete(path). It provides exception: "Additional information: The process cannot access the file 'C:\Images\2014_09\auto_12_53_55_beszelri_modified.jpg' because it is being used by another process".
I'm trying call this method in Window_OnClosed event. The idea is that I have to delete image's jpg file when I'm closing the window. Path of this file is the source of image control in WPF. I was trying set Image source to null before call that method but it doesn't work. How can I delete that file after or during close the window. When I tried close other file in that place it was succesfull.
This is the code of closed event. The CreateFileString method create the path.
private void ImageWindow_OnClosed(object sender, EventArgs e)
{
var c = CarImage.Source.ToString();
var a = CreateFileString(c);
CarImage.Source = null;
File.Delete(a);
}