Click here to Skip to main content
15,905,136 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,
I currently have an XML configuration file called ProjectFiles.dtsConfig created under SSIS that contains five variables SrcFile1, SrcFile2, SrcFile3, SrcFile4 and SrcFile5. Each has a value defining the location and name of a unique file, where each can be in a different location. Over time I will be adding and removing the file variables from the config file, but the variable names for the files to be copied will always begin with "SrcFile".

Is there a way, using expressions or scripting or whatever, to dynamically loop through and copy the files associated with variables in the schema file that begin with "SrcFile"? I have looked into applying different enumerations under the Foreach Loop Container in an SSIS package and would like to avoid hardcoding the variable names (SrcFile1, SrcFile2, etc.), as there may eventually exist a SrcFile6, SrcFile7 and so forth in the future.

Thanks,
Kosh2010
Posted
Updated 7-Aug-12 10:01am
v3
Comments
Sergey Alexandrovich Kryukov 7-Aug-12 12:56pm    
Not a nice question. If you have a problem you cannot solve, just describe it, don't tell us what to use to solve it (like in "apply foreach loop")...
--SA
Kosh2010 7-Aug-12 13:20pm    
Sergey,
Do you mean that it was not a "proper" or "good" question? Saying that my question was not "nice" implies that it hurt your feelings, which hopefully is not the case.

I've successfully applied the Foreach Loop container in the past and it seems like the most appropriate approach here. But I am certainly open to alternatives. If you have experience with SSIS and have a better idea, please share.

Thanks

1 solution

I have decided to change my approach with regard to the objective of this issue. The objective is to iterate through a specific list of files defined in a list of other files and copy them from different locations to a single location. Instead of defining the file paths using variables in an XML configuration file, I've decided to define the file paths in a new database table where it is much easier to capture the list of files using an Excecute SQL Task and then passing that result on to a Foreach Loop container that will apply a file system task of copying each file using the passed file enumerator. Maintenance with this approach is also simpler. This approach resolved the issue and was easy to set up.

Using an XML configuration file in the original approach defined is not practical.

Thanks,
Kosh2010
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900