本文介绍了创建BitmapImage后,C#4.0解锁图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我从现有的图像创建一个BitmapImage使用:

  BitmapImage bmp = new BitmapImage 
bmp.BeginInit();
bmp.UriSource = new Uri(jpegPath,UriKind.Relative);
bmp.EndInit();

在我这样做后,我想从我的硬盘驱动器删除的图像,但它被锁定。

解决方案

bmp .CacheOption = BitmapCacheOption.OnLoad;



这会将图像完全加载到内存中,并且不会在图像文件上留下锁。 / p>

I am creating an BitmapImage from an existing image using:

BitmapImage bmp = new BitmapImage();
bmp.BeginInit();
bmp.UriSource = new Uri(jpegPath, UriKind.Relative);
bmp.EndInit();

After I have done this I want to delete the image from my hard drive, but it is locked.Is there a way I can unlock it so it can be removed?

解决方案

bmp.CacheOption = BitmapCacheOption.OnLoad;

That will load the image into memory completely and won't leave a lock on the image file.

这篇关于创建BitmapImage后,C#4.0解锁图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 01:24