** Process cannot access the file


I am trying to read the file and adding to the queue. once the process is complete - it should be deleted from the input folder. It works perfectly in my machine, and two other environments. when implemented in production and tested - i am getting like " The process cannot access the file “****\input.xlsx” because it is being used by another process.

I tried to look out few other threads as well, it didnt give me proper solution. Any help on this?


Have you tried using a Close or Kill activity to ensure excel is not running in the background?

you mean after reading the excel? what exact activity to be used? any sample u can show? like a pic or somethign…


Yes, after you are done performing excel activities, you can use the ‘Close Workbook’ activity. If that doesn’t work, you can use a Try-Catch or similar error handling process and Kill excel if needed. Search for ‘Kill Process’ in the activities search bar.

1 Like

Hi @Pradeep.Robot,

@bradsterling’s solution is good. You can also fix this issue by using excel “Read Range” activity inside an excel application scope, instead of workbook “Read Range” activity. After adding the data to queue, you can use a “Delete” file activity outside the excel application scope to delete that file.

Warm regards,

1 Like

ok! you meant kill process only, I tried that approach already, it didnt work… :frowning:

I cannot delete immediately after the read range, as i need to have this file till my last module of archiving and mailing! else i could have tired that way.

So, after you use ‘Kill Process’, the error: “The process cannot access the file “*** *** \input.xlsx” because it is being used by another process.” still persists?

Once you read the file, the data is stored in a DataTable variable. If you delete the file after you read the range, you can still perform whatever operations you would like on the queue using the DataTable variable.

Upload an example of what you’re trying to accomplish and the Community can help you problem solve.

Process would be : Read the excel to Queue -> Process some logics -> update the status in that excel -> send the sheet in the mail -> Delete the file from the path (so that the place will be there for the next input.

I have killed the process after reading it and writing the output (before sending mail). cannot delete the process once the read action to the queue is done :neutral_face: i have the delete file activity right after sending the mail with the delay.

Check this - the file handle might not be released

@andrzej.kniola - Thanks for response. I checked the link already, I have used the system.gc.collect in the finally on send mail activity. but still it didnt work… even the solution is unsaid in the link which you have shared. I can change the logic and fix it somehow… but, just want to identify the root cause of it. As it was working fine with other environments.

And the finalizers invoke?

This would be the next step, without code its hard to say more.

Last check - make sure no other user has the file open and just left for vacation…
Check with a dummy file if it works to eliminate that this particular file is borked.

1 Like

@andrzej.kniola - Finalizers worked finally. Thanks for pointing out. I was working with GC.Collect.

Any idea on why its not working specifically with this environment? and without these GC handling it works in other environment? anything to tweak/take care on environment specific?

It could be almost anything, unfortunately, but this is most prevalent with slow disks or shared drives.
In any case, the real problem is in the send mail activity - it should release the handles before returning.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.