File is used in another process

  • Thread starter Thread starter Kashif Javed
  • Start date Start date
K

Kashif Javed

Hi there

My small OCR program is written in VB .NET. The main procedure uses the
FSO and scans a folder for image files and then send each file name to a
Function which does the OCR using MODI and extracts the text out of
that image file and returns the extracted text to the main procedure.
After extracting the text out of that image file the program tries to
delete the file but it gives an error message "File is being used in
another Process".
The VB 6 version of the program is working fine.
Any suggestions or help will be appreciated?
Thank you

Kashif
 
With FSO I assume you mean FileSystemObject. In the .NET version I would
recomend you use the native .NET IO classes, instead of the COM objects.

How do you delete the file? Do you delete using a reference or a filename?
If you delete it using the filename, there might still be a reference active
to the file.
VB 6 and VB.NET have different garbage collection systems, objects may hang
around longer in the .NET version before they are collected. I think VB 6
uses a reference counting system. The VB 6 version might release the object
faster than the .NET version.

File handles are a limited resource, you should always explicitly release
them.

Chris
 
Back
Top