Exception: File is being used by another process

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
engmac
Posts: 5
Joined: Mon Nov 11, 2013 11:06 am

Exception: File is being used by another process

Post 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
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Exception: File is being used by another process

Post 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.
Lars Arvidsson, Axolot Data
engmac
Posts: 5
Joined: Mon Nov 11, 2013 11:06 am

Re: Exception: File is being used by another process

Post 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
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Exception: File is being used by another process

Post 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.
Lars Arvidsson, Axolot Data
engmac
Posts: 5
Joined: Mon Nov 11, 2013 11:06 am

Re: Exception: File is being used by another process

Post by engmac »

The "preview pane" in windows 7 was creating the problem.
Post Reply