本文介绍了BitmapImage的WPF中做锁定文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的:

Dim bmi As New BitmapImage(New Uri(fiInfo.FullName, UriKind.Absolute))
bmi.CacheOption = BitmapCacheOption.OnLoad

这并不使用的OnLoad 而文件仍然锁定为改写硬盘。任何想法如何解锁?

this does not Use OnLoadAnd file still is locked to overwrite on harddisk. Any idea how to unlock?

问候

推荐答案

如图您链接到的问题,你需要调用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:

Dim bmi As New BitmapImage()
bmi.BeginInit()
bmi.CacheOption = BitmapCacheOption.OnLoad
bmi.UriSource = New Uri(fiInfo.FullName, UriKind.Absolute)
bmi.EndInit()

这篇关于BitmapImage的WPF中做锁定文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 00:17