Delete Activity Error

Hello All,

I’m trying to perform below action :

From a directory that contains multiple folders, I’m opening text file with excel from each folder, changing the content of excel, saving back it into same text format and compressing each folder.

In the end I’m cleaning up the folders in the directory. While performing this action i’m getting error as : the process cannot access the file because it is being used by another process. Can anyone help me on this.

Hi Manjusha,

Please check the solution in this topic:

I’m opening the text file using processStart = System.Diagnostics.Process.Start(“EXCEL.Exe”, File.ToString). When I’m commenting this portion of code, The files are getting deleted properly. I suspect there is some issue cleaning the files which I’m opening using processStart. Do I need to kill the process after I’m opening text file with processStart.

I’m thinking yes. It seems to remain open somehow and that’s why yo get the error. So close it before delete.

Hi Ovi,

I’m closing the saved excel by giving alt + f4 and when I tried to kill the process, its throwing the error that process has exited.

Have you tried with Invoke method like in the example in the topic above?

Should I add this before cleaning up directories?Capture