0

I am trying to download files from an FTP server using a SSIS Script task, I am using the class 'ftpClientConnection' class and in it tried using the 'ReceiveFiles' method to download files from the FTP location to my local folder. But I am getting some exception error, when I debugged the Script task I find that the exception occurs in the 'ftp.connect()' line. I have passed all the required arguments while creating the object for 'ftpClientConnection'. To debug in an other way I simply tried using the FTP task, even here I am getting an error of "Connection cannot be established". FYI I am able to log in to the FTP location with the service credentials that I am provided in both my script task and FTP task.

PS: I am new to VB.net

Code Here

    Dim cm As ConnectionManager = Dts.Connections.Add("FTP")

    'Set the properties like username & password

    cm.Properties("ServerName").SetValue(cm, "ftp://<ftpname>/")

    cm.Properties("ServerUserName").SetValue(cm, "<username>")

    cm.Properties("ServerPassword").SetValue(cm, "<password>")

    cm.Properties("ServerPort").SetValue(cm, "21")

    cm.Properties("Timeout").SetValue(cm, "0") 

    cm.Properties("ChunkSize").SetValue(cm, "1000")

    cm.Properties("Retries").SetValue(cm, "1")


    Dim ftp As FtpClientConnection = New FtpClientConnection(cm.AcquireConnection(Nothing))


    ftp.Connect()

    Dim remotefilenames() As String = {"<ftpfolder/filename.txt>"}

    Dim localpath As String = "<C:\localfolder\FTPDestination\>"

    'Build a array of all the file names that is going to be downloaded (in this case only one file)

    ftp.ReceiveFiles(remotefilenames, localpath, True, True)

    ftp.Close()

I am getting an excpetion right at the "ftp.connect()" line

Prakazz
  • 421
  • 1
  • 8
  • 21

0 Answers0