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?
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.
@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.
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.
@Pradeep.Robot
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 i have the delete file activity right after sending the mail with the delay.
@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.
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.
@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.