I am running into some trouble overwriting an image file (A generic error occurred in GDI+).
I am now trying to delete the file before saving (since I can't seem to overwrite it). I am using this code to delete the file:
Dim PartImgFile As FileInfo = New FileInfo(ImagePathOpened.Text & "\PartImage.jpg") If PartImgFile.Exists Then File.Delete(ImagePathOpened.Text & "\PartImage.jpg") End If
With this I am getting an error that the file cannot be deleted because it is being used.
Can someone please give me an idea on how to delete this file or overwrite it?