I have the following code:
imgScreenshot.Source = new BitmapImage(new Uri(ShellFolder.DocumentsFolder() + System.IO.Path.DirectorySeparatorChar + screenshot.Filename));
File.Delete(ShellFolder.DocumentsFolder() + System.IO.Path.DirectorySeparatorChar + screenshot.Filename);
I get an error:
{"The process cannot access the file 'C:\Users\rover\Documents\MagicScreenshot\vEhWg3Ra20M.jpg' because it is being used by another process."}
I thought about dispose BitmapImage, but this class does not realize this interface. How to write this code correctly?