Load a BitmapSource and save using the same name in WPF -> IOException

后端 未结 5 798
太阳男子
太阳男子 2020-12-21 00:53

When I try to save a BitmapSource that I loaded earlier, a System.IO.IOException is thrown stating another process is accessing that file and the filestream can

5条回答
  •  清酒与你
    2020-12-21 01:21

    Now i'm not sure if this can be applied to BitmapImage but i had a very similar problem with saving a modified image to the original file in GDI+ here

    The method of loading the image from file keeps a lock open on the file until the image object is disposed.

    Maybe it's the same thing with bitmapimage.urisource. Without playing around could you copy the image in memory and dispose the original thus unlocking the file?

提交回复
热议问题