February 5, 2016 at 9:05 am
I have a For Each Loop that contains a process task where Im calling 7 Zip to create a zip file which contains several txt files. Sometimes it runs fine but other times I get an error saying: "The process cannot access the file because it is being used by another process. cannot delete the file \\directory path\[the name of the zip file that its creating].
Seems like the process tries to access the zip file before the the lock from the last execution of the foreach loop has been removed. Is there a way to ensure that this doesn't happen?
February 5, 2016 at 9:26 am
I think what you're seeing is Windows being slow at releasing control of the file. I've had similar problems with file system operations when looping very quickly through a list of files. In one package, I had to add a short wait (1-2 sec) in the loop to stop this from happening.
One thing you could try, is, on error, wait 2 seconds, then try again.
For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]
February 5, 2016 at 12:18 pm
Added an Exe sql task with WAITFOR DELAY '00:00:02'; in the foreach loop before the exe process task calling 7 zip but still getting error
February 8, 2016 at 5:49 am
dndaughtery (2/5/2016)
I have a For Each Loop that contains a process task where Im calling 7 Zip to create a zip file which contains several txt files. Sometimes it runs fine but other times I get an error saying: "The process cannot access the file because it is being used by another process. cannot delete the file \\directory path\[the name of the zip file that its creating].Seems like the process tries to access the zip file before the the lock from the last execution of the foreach loop has been removed. Is there a way to ensure that this doesn't happen?
I've read this three or four times and I don't understand what's going on.
If you are creating a Zip file, why would you ever get a 'cannot delete' type error?
If your FEL contains the EP task, the EP task is executed on every iteration of the FEL. Yet you refer only to the 'last execution of the FEL'. Why are you calling the EP task repeatedly?
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
February 8, 2016 at 6:31 am
I have several files in the folder that need to be zipped into the same zip file
February 8, 2016 at 6:39 am
dndaughtery (2/8/2016)
I have several files in the folder that need to be zipped into the same zip file
OK, but this does not answer my questions.
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply