Image C#4.0在创建位图图像后解锁图像
我正在使用以下命令从现有图像创建位图图像:Image C#4.0在创建位图图像后解锁图像,image,c#-4.0,bitmapimage,Image,C# 4.0,Bitmapimage,我正在使用以下命令从现有图像创建位图图像: BitmapImage bmp = new BitmapImage(); bmp.BeginInit(); bmp.UriSource = new Uri(jpegPath, UriKind.Relative); bmp.EndInit(); 完成此操作后,我想从硬盘中删除图像,但它已被锁定。 有没有办法解锁它以便将其删除?JPG仍然设置为应用程序中现有对象的源。尝试将BitmapImage的源设置为其他内容或将其完全删除。或者在内存中创建JPG的副
BitmapImage bmp = new BitmapImage();
bmp.BeginInit();
bmp.UriSource = new Uri(jpegPath, UriKind.Relative);
bmp.EndInit();
完成此操作后,我想从硬盘中删除图像,但它已被锁定。
有没有办法解锁它以便将其删除?JPG仍然设置为应用程序中现有对象的源。尝试将BitmapImage的源设置为其他内容或将其完全删除。或者在内存中创建JPG的副本。
bmp.CacheOption=BitmapCacheOption.OnLoad代码>
这样会将图像完全加载到内存中,并且不会在图像文件上留下锁