I have a VB program that displays images to the user and lets them associate it with a database record. That part works fine. My problem comes when I try to move the image file to another folder after the indexing is done. I get a Windows error "The process cannot access the file because it is being used by another process." The name of the Windows control is gdviewer1. I've tried putting gdviewer1.clear() and gdviewer1.CloseImage() just before the file.move statement and I still get the error. If I put a gdviewer.dispose() statement just before the file.move then the move works but, of course, the program dies because I killed the control.
Is there something I'm missing?
Here's the code segment that's failing:
- Code: Select all
Dim ImageIdx As Integer
Dim DirList As DirectoryInfo
Dim FileList() As FileInfo
Dim QueueList() As DirectoryInfo
Dim ImageRootIn As String = "", ImageRootSave As String = "", FPath As String = ""
.
.
.
ThisImageFile = FPath + CB_WorkingQueue.Text & "\" + FileList(ImageIdx).Name
GdViewer1.CloseImage()
GdViewer1.Clear()
File.Move(ThisImageFile, ImageRootSave + FileList(ImageIdx).Name)
The stranger thing is that this code worked fine with the evaluation copy of gdpicture.