Page 1 of 1

Exception: File is being used by another process

Posted: Mon Nov 11, 2013 11:08 am
by engmac
Hi,

I´m using XE3 (CodeGear / Embarcadero) and XLSReadWriteII 5.

My code requires cyclical reads and writes from XLSX file.

By now the XLSX file has less tahn 500KB size.

I´m getting often an execption at the middle of the executation of my code, that the file is being used by another process... when it happens I need to abort the executation of my code.
The unique process that is using that file is the code that I´m running. It seems that the write to my file takes to much time and then when I have the next write action it will not be possible because the XLS file still being write...

In order to solve this issue I would like to know, what Flag could be used to test is any XLSX file is ready to be saved/readed....If the flag would state that file is not ready I would implement a delay in ordert to try to get acess later.

Could you point me out what flat would I test... or point another work arround.

thanx

Re: Exception: File is being used by another process

Posted: Mon Nov 11, 2013 1:19 pm
by larsa
Hello

Do you have more than one thread running with the component(s) writing to the same file? You can't get this error message if all your writes take place in the same thread, unless for the obvious reason, there is in fact another application (not yours) that is using the file.

Re: Exception: File is being used by another process

Posted: Fri Nov 15, 2013 12:09 pm
by engmac
Hi,

I´m not working with threads in a explicit manner.

So, would be the same tread that is trying to write in the XLSX file that is under a older write process. There is no other application using the same XLSX file.

Will the XLSX driver hold the program flow, until a XLSX save is done, and then this error will never happen? or it will release the program flow and then perform the save/write in the hard drive after?

thx

Re: Exception: File is being used by another process

Posted: Fri Nov 15, 2013 3:21 pm
by larsa
Hello

A file can not overwrite itself in a single thread application. It's impossible. If you receive such a error message it's because it's true. The file is opened by another application.

Re: Exception: File is being used by another process

Posted: Wed Nov 20, 2013 9:30 am
by engmac
The "preview pane" in windows 7 was creating the problem.