SSIS For Each File Loop and File System Task to co

2019-02-27 09:25发布

问题:

I'm using a files system task inside a for each loop container, just as described here: link text

However, when I execute the package I get this error: [File System Task] Error: An error occurred with the following error message: "The process cannot access the file 'C:\Book1.xlsx' because it is being used by another process.".

I do not have the file open, and I assume no one else does, as I am able to copy, and open, and overwrite the file.

Any suggestions would be appreciated. If you want an example package plz let me know.

回答1:

I've figured out the problem. Be sure to not create File connections(you can see them in the Connection Managers tab) that hold on to the same variable as the path you are using for the source file, in the File System Task.



回答2:

Since this took me MANY HOURS to solve, I'm posting my solution for others. And it was sooo simple...

Place a copy of your Excel File in another folder and name it "template.xlsx". Have your Schema connection point to this copy. The actual Excel file will no longer be kept locked by the ForEach Worksheet Schema loop!