图像文件加载锁定在WPF后 [英] Image file locked after loading in WPF

查看:172
本文介绍了图像文件加载锁定在WPF后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读我的WPF的ImageSource是这样的:

I am reading my WPF imagesource like this:

dim bmi as new bitmapimage()
bmi.begininit()
bmi.cachoption = None
bmi.UriSource = new Uri(MyFileName, Urikind.Absolute)
bmi.endedit

它的工作原理像它应该到了这一点。 但是用户可以通过复制文件更新图像。 然后,我要刷新的图像。但文件MyFileName的被锁定,当我想要做覆盖它,它抛出一个错误,这是已经在使用并锁定。

It works like it should until this point. But 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 do overwrite it, it throws an error that it is already in use and locked.

别急,我在这里寻找一个解决方案,我知道了:

But wait, I searched here for a solution and I got it:

bmi.cachoption = OnLoad

是关键... BUT!现在,图像总是旧,并且不更新为新的文件。 如何清除这个缓存?

was the key... BUT!! now, the image is always the old one and is not updated to the new file. How to clear this cache?

在VB.Net我从流中System.Drawing.Bitmap。如何做到这一点最好的办法在WPF?

In VB.Net I made an System.Drawing.Bitmap from stream. How to do it best way in WPF?

问候

推荐答案

dlev有一个很好的建议。这里你可以看到缓存选项来解决这个问题:<一href="http://stackoverflow.com/questions/1688545/wpf-problems-overwriting-re-saving-image-when-it-was-set-as-image-source">WPF - 覆盖问题(重新保存)图像时它被设定为图像源

dlev had a good advice. Here you see the cache option to solve it: WPF - Problems overwriting (re-saving) image when it was set as image source

imgTemp.CreateOption = BitmapCreateOptions.IgnoreImageCache

这篇关于图像文件加载锁定在WPF后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆