I want to be able to open/view a image (.jpg) without locking the file. Basically I have a program that lets the user choose a picture that will overwrite a picture. But the problem is that I display the image that is being overwritten. So how do I load an image without locking it?
This is the code I have to set the image right now
Image1.Source = new BitmapImage( new Uri( myFilePath ) ) );
myFilePath is equal to a string that would something like “C:\Users*\My Pictures\Sample.jpg”
myBitmap.CacheOption = BitmapCacheOption.OnLoadis the line you’re looking for. It “caches the entire image into memory at load time. All requests for image data are filled from the memory store.” From MSDNSomething like this: