I read my WPF image sources as follows:
Vb
Dim bmi As BitmapImage = New BitmapImage bmi.BeginInit bmi.CacheOption = BitmapCacheOption.None bmi.CreateOptions = BitmapCreateOptions.IgnoreImageCache bmi.UriSource = New Uri(input.FullName, UriKind.Absolute) bmi.EndInit
WITH#
BitmapImage bmi = new BitmapImage(); bmi.BeginInit(); bmi.CacheOption = BitmapCacheOption.None; bmi.CreateOptions = BitmapCreateOptions.IgnoreImageCache; bmi.UriSource = new Uri(input.FullName, UriKind.Absolute); bmi.EndInit();
It works as it should, up to this point. But the user can update the image by copying the file. Then I want to refresh the image. But the file "MyFileName" is locked, and when I want to overwrite it, it gives an error message, which it is already in use and locked.
But wait, I was looking for a solution here, and I got it:
bmi.cachoption = OnLoad
was the key ... BUT! Now the image is always old and is not updated to a new file. How to clear this cache?
In VB.Net, I created System.Drawing.Bitmap from a stream. How to do it best in WPF?
Hello
source share