WPF释放图像资源, [删除时报另一进程占用]

Posted 风雨丛中住着一只南飞的雁,

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了WPF释放图像资源, [删除时报另一进程占用]相关的知识,希望对你有一定的参考价值。

源:zhantianyou

CODE

        private BitmapImage ReturnBitmap(string destFile)
        {
            // Read byte[] from png file
            BinaryReader binReader = new BinaryReader(File.Open(destFile, FileMode.Open));
            FileInfo fileInfo = new FileInfo(destFile);
            byte[] bytes = binReader.ReadBytes((int)fileInfo.Length);
            binReader.Close();

            // Init bitmap
            BitmapImage bitmap = new BitmapImage();
            bitmap.BeginInit();
            bitmap.StreamSource = new MemoryStream(bytes);
            bitmap.EndInit();
            return bitmap;
        }

 

以上是关于WPF释放图像资源, [删除时报另一进程占用]的主要内容,如果未能解决你的问题,请参考以下文章