I am having trouble using the delete funciton in Visual Basic.
Here is my code:
My.Computer.FileSystem.DeleteFile(PhotoFileName, _
FileIO.UIOption.AllDialogs, FileIO.RecycleOption.SendToRecycleBin)
The files are selected from a listbox and a preview is shown in a picture preview control.
The delete function works sometimes, but for some reason, it shows that the file I am trying to delete is 'In use by another application' - even though this is not the case.
I had thought that the problem was that it was being used by the Photo preview control, so cleared it as follows:
If Not (PhotoRenamerMain.PhotoPreview.Image Is Nothing) Then
PhotoRenamerMain.PhotoPreview.Image.Dispose()
PhotoRenamerMain.PhotoPreview.Image = Nothing
End If
Can someone help? Is ther an obvious error here? Is it possible to programmitically close all applications which may have my target file open?
I am a bit of a newbie to programming...Your advice is appreciated.