Using the script task below to stuff list of files into User::ftp_file_list. But, the For Each Loop container in the next step returns the error "Foreach Loop Container: The object in the variable "User::ftp_file_list" does not contain an enumerator."
OK, turns out that the issue is that the connection is not being made. The thing I don't understand is that I've tested the connection independently without any trouble. So, I'm a bit perplexed why it's not connecting in the script task.
Anyone have any thoughts? Thanks in advance!
Public Sub Main()
Dim result As Integer
Dim manager As ConnectionManager
Dim ftpClient As FtpClientConnection
Dim foldersList As String()
Dim filesList As String()
Dim var As Variables
manager = Dts.Connections("FTP_Connection")
ftpClient = New FtpClientConnection(manager.AcquireConnection(Nothing))
Try
If ftpClient.Connect() Then
Call ftpClient.SetWorkingDirectory(Dts.Variables("ftp_path").ToString)
Call ftpClient.GetListing(foldersList, filesList)
' Store files list in package variable.'
Call Dts.VariableDispenser.LockOneForWrite("ftp_file_list", var)
Try
var("ftp_file_list").Value = filesList
Finally
Call var.Unlock()
End Try
End If
Catch ex As Exception
result = Dts.TaskResult = ScriptResults.Failure
Call Dts.Events.FireError( _
0, _
String.Empty, _
ex.Message, _
String.Empty, _
0)
Finally
Call ftpClient.Close()
End Try
Dts.TaskResult = ScriptResults.Success
End Sub ' Main