My app repeatedly displays a TIF file from a directory and closes them. But when I try to rename the file later, VB says that it is in use by another process. Here is the code:
Imports System.IO
Dim imgRight As Image
Dim fileRight as String
fileRight = "C:\1_Audit\PD_SE-4423344\PD_SE-4423344_0008.tif"
imgRight = Image.FromFile(fileRight)
Me.PicBoxRight.Image = imgRight
.
.
.
Me.PicBoxRight.Image.Dispose()
Me.PicBoxRight.Image = Nothing
imgRight.Dispose()
.
.
.
oldFileName = fileRight
newFileName = "PD_SE-4423344_0006.tif"
My.Computer.FileSystem.RenameFile(oldFileName, newFileName)
What do I have to do to release fileRight???