WPF 中的 BitmapImage 会锁定文件
我使用:
Dim bmi As New BitmapImage(New Uri(fiInfo.FullName, UriKind.Absolute))
bmi.CacheOption = BitmapCacheOption.OnLoad
这不 使用 OnLoad 并且文件仍然被锁定以覆盖硬盘上。知道如何解锁吗?
问候
I use:
Dim bmi As New BitmapImage(New Uri(fiInfo.FullName, UriKind.Absolute))
bmi.CacheOption = BitmapCacheOption.OnLoad
this does not Use OnLoad
And file still is locked to overwrite on harddisk. Any idea how to unlock?
Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如您链接到的问题所示,您需要像这样调用 BeginInit 和 EndInit 以及设置 UriSource 属性:
As shown in the question you link to, you'd need to call BeginInit and EndInit, like so as well as set the UriSource property:
从文件中读取 BitmapImage 并使用 MemoryStream 重写它:
Read the
BitmapImage
from file and rewrite it with aMemoryStream
:我有一个类似的问题,我用这个方法解决了:
(这是答案的个性化此处)
您可以打开图像像这样:
加载后立即释放图像。
希望它能有所帮助!
I had a similar problem and I solved using this method:
(it's a personalization of an answer here)
You can open the image like this:
And it releases the image immediatly after loading it.
Hope it can helps!