Thursday 24 May 2012

System.IO.IOException: The process cannot access the file because it is being used by another process.

If you encounter this error that mean that you are trying to access a file which is not closed at the moment. The file your trying to access is still open, below is the screen-shot:




















Solution:

The solution is that you simple need to close the file the TextIO class. For closing the file you neeed to use this syntax:

TextIo inputFile;
;

inputFile.finalize();

// This will close the file and then you can proceed with your remianing operation on the file.

4 comments:

  1. Thanks - this problem was driving me crazy. Great job!

    ReplyDelete
  2. This method is private.. and it's driving me crazy now

    ReplyDelete
  3. Damn.. I have been struggling the whole day. When generating file on client side file = null works. But when running in a batch need to finalize..

    ReplyDelete