Okay I;m really new to VB.NET and desktop application development. Simplified this is what is happening in my application:
Dim Files() As New List(Of IO.FileInfo)
Files.Add( (New IO.FileInfo("C:\img1.jpg")) )
Files.Add( (New IO.FileInfo("C:\img2.jpg")) )
'Picture is a Windows.Forms.PictureBox in my WinForm '
Picture.Image = New System.Drawing.Bitmap(Files(0).FullName)
Picture.image = Nothing
CurrentFile = Files(0)
'Show next pic (img2)'
Files.RemoveAt(0)
Picture.Image = New System.Drawing.Bitmap(Files(0).FullName)
'Move img1 to other location '
CurrentFile.MoveTo("C:\other\img1.jpg")
The last line will throw an Exception saying that img1 cannot be moved because it is in use. So my application is still using it, but how to make my application stop locking the file? There is nothing keeping a refrence to it (as far as I see)