I would like to bind an Image to some kind of control an delete it later on.
path = @"c:\somePath\somePic.jpg"
FileInfo fi = new FileInfo(path);
Uri uri = new Uri(fi.FullName, UriKind.Absolute);
var img = new System.Windows.Controls.Image();
img.Source = new BitmapImage(uri);
Now after this code I would like to delete the file :
fi.Delete();
But I cannot do that since the image is being used now.
Between code fragment 1 en 2 what can I do to release it?
copy the image to MemoryStream before giving to imagesource
it should look like this
where byteStream is copy of file in MemoryStream
also this can be useful