SSIS Script Task C#

  • Hi All,

    I need to import files based upon their last edited date. So for example today I may receive two files and tomorrow i may receive four. I can write a console app which checks the provided directory and returns all of the files modified today. How can I then loop through those files via ssis to import them?

    Thank you all in advance,

    Paul

  • Hi,

    You should look into utilizing the ForEach object from the Toolbox. You can configure it to loop through each file in a directory and have a process within the ForEach to handle each file.

    From BOL about the ForEach:

    http://msdn.microsoft.com/en-us/library/ms141724.aspx

    Generally, you'd have a list of flat files to import, so the foreach would, at a bare minimum, contain a data flow task to load the data from the file.

    There are many examples online if you search the foreach enumerate for processing files.

    Best regards,

    Steve

  • Hey Steve,

    Thank you very much for your response. Despite my weak C# skills I was able to write a script which could identify all files with a last edited date of today. In that script I use a foreach loop to iterate through the list of files which were edited today. From there I use the StartsWith method to determine which file is which and set the connection strings right in there. If your interested I can post the script. Again, thanks soo much for taking the time to offer a possible solution.

    Thank you,

    Paul

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply