Access to file protected

nooch32

Member
Joined
Oct 25, 2006
Messages
17
Programming Experience
3-5
I have a folderwatcher set up to watch a folder.

When it finds a new file, it renames the file (if needed) and then loads the file up into a pic box. The error i'm getting is:

"Exception has been thrown by the target of an invocation"


Which isn't a great error message, but after looking into the detail of the error, it is because it can't use the file because it's in use.

So i'm guessing i need to do a

Try

Catch ex As Exception

End Try

I just wondered if anyone else had any solutions to file protection? I'm sure i'm closing my file object used to rename the file, but i think the program is running faster than the disk/windows file access, so the file is still in a locked state.

Any ideas or pointers would be greatly appreciated

Danny
 
Back
Top