TomPhillips
Active member
- Joined
- Feb 24, 2005
- Messages
- 33
- Programming Experience
- 10+
File in use by another process. RESOLVED
I have an app that moves files around, renames, selects and deletes JPEGs. It uses a thread to copy groups of up to 200 files of 50 to 100K each. While The thread is running, it updates a form to let the user know when a group of files has been copied to the work area, so they can start "processing" them. Processing means displaying some in a list view for selection and deletion. Then the an explorer window is opened so that groups of files can be "dragged" into another application for image manipulation.
Frequently, I get the error "File in use by another process..." even though the "background" thread is finished with the named file. I have been told that this is a "garbage collection" issue.
So do I need a "System.GC.collect() after each
System.IO.File.Copy(Source, Destination, True)?
Or is there a better way to release a file imediately that the process is done with?
I have an app that moves files around, renames, selects and deletes JPEGs. It uses a thread to copy groups of up to 200 files of 50 to 100K each. While The thread is running, it updates a form to let the user know when a group of files has been copied to the work area, so they can start "processing" them. Processing means displaying some in a list view for selection and deletion. Then the an explorer window is opened so that groups of files can be "dragged" into another application for image manipulation.
Frequently, I get the error "File in use by another process..." even though the "background" thread is finished with the named file. I have been told that this is a "garbage collection" issue.
So do I need a "System.GC.collect() after each
System.IO.File.Copy(Source, Destination, True)?
Or is there a better way to release a file imediately that the process is done with?
Last edited: