Bulk Insert Problem

  • I'm trying to bulk insert a number of files in a folder with an SSIS package. I am trying to build a list of files for the ForEach Loop Container to process. However, the Script Task that builds the User::FileList isn't working. There are 3 files in the folder, but the User::FileList is empty after the Script Task tries to build it - the ReadWriteVariables is set to FileList & the script does set it after it loops through the files from the Get File statement.

          Dim localFiles() As String

            Dim localFile As String

            listForEnumerator = New ArrayList()       

          Try

                localFiles = Directory.GetFiles("C:\Apps\IIS1")

                For Each localFile In localFiles

                    listForEnumerator.Add(localFile)

                Next

            Catch

            End Try

            Dts.Variables("FileList").Value = listForEnumerator

            Dts.TaskResult = Dts.Results.Success

    I put some MsgBox statements in the script & determined that the GetFiles statement fails & the logic proceeds to Catch, which currently does nothing.

    I've seen this sort of thing in examples all over the Internet & don't understand the problem. I checked the directory security & it appears fine. Any help is greatly appreciated.

  • You shouldn't need to build your file list with a script task.  The foreach loop container allows you to loop through files in a specific folder.  Select "Collection" in the foreach loop container, then select the "Foreach File Enumerator" from the Enumerator drop down list.  The configuration also allow you to fine tune the list of files you want to loop through.

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

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