I have an that turns on a webcam and takes a picture of a barcode; this part works fine but I now want to display the picture taken on screen.
I have created the image control in the axml file as follows:
<Image x:Name="BarcodeImage" Margin="5" Height="240" Width="450"/>
As you can see I haven't actually set an image yet as there is nothing to show.
Once the picture has been taken, I save the image to my hard-drive; this works correctly as I can view the image from my PC.
I am then setting the image in code as follows:
this.BarcodeImage.Source = new BitmapImage(new Uri(filename));
This works correctly and I can now see the taken image on the screen.
My problem occurs if I wish to scan a different barcode; I cannot save the next picture taken as the filename already exists so I am trying to delete the picture before saving the next but I keep getting the error message "the file may be in use by another process".
I have tried having a default image that I set to before deleting (hoping that image I want to delete is now not being used), but now both images cannot be deleted (even manually) as they are both being used by another process.
I have also tried setting the image.source to null, but this does not work either.
Do you have any suggestions on how I can delete my image or to clear the current image set?