I have an image control with the original image located on my c drive. I get a message that the image is being used by another process when I try to delete the original image in order to change it using another dynamically. How to remove an image from an image control to remove it.
I tried the following options:
string path = ((BitmapImage)img.Source).UriSource.LocalPath; img.SetValue(System.Windows.Controls.Image.SourceProperty, null); File.Delete(path);
and
string path = ((BitmapImage)img.Source).UriSource.LocalPath; img.Source = null; File.Delete(path)
But it does not work ...
source share