As part of automation I create 6 excel files in the working folder. I delete the files from the working folder before every run. This works 90% of time but 10% of time the bot fails at the delete step.
There are no files in the folder in the folder. I rerun the bot and I get the same error until I restart the machine. I have created a test bot to show the steps.
Error : File:com.automationanywhere.botcommand.exception.BotCommandException: Unable to delete the file(s) 'C:\Automation Anywhere\Management Reporting and Planning\Working Folder\~$EmpManagerMapping_022024.xlsx' because access is denied. - 16
Page 1 / 1
Hi @Sai Deepan.R ,
Please try the below steps to fix this.
Check File Permissions: Ensure that the files you're trying to delete are not being used by another process or program. Sometimes, a file might be locked by another application, preventing it from being deleted. You can try closing any applications that might be using these files and then attempt to delete them again.
File Handle Release: Ensure that your automation script is properly releasing any file handles it might be holding onto after reading or writing to the files. Failing to release file handles can sometimes prevent files from being deleted.
If the file used any where/ subtasks, please make sure to close the excel session.
Delay Before Delete: Introduce a small delay before attempting to delete the files. This can give any processes that might be using the files enough time to release them before your automation script tries to delete them.
Thanks @Tamil Arasu10 for the reply.
The file doesn't exist in the folder so there is no issue with the permission or file release as per my knowledge. If condition does file exists returns true even when there is no file in the folder. This gets fixed when I restart the machine. I think this could be something to do with temp file reference ?
Error : File:com.automationanywhere.botcommand.exception.BotCommandException: Unable to delete the file(s) 'C:\Automation Anywhere\Management Reporting and Planning\Working Folder\~$EmpManagerMapping_022024.xlsx' because access is denied. - 16
Can this be an issue since I am deleting simultaneously
You're correct.
The session ends when you restart the machine. After that, it works fine.