How to send many files to FTP server

  • Hello,

    Has anyone coded a script task that will upload 2 or more files to an FTP folder?

    I have done the same using a ForLoop and an FTP task but I need the code in a Script task that will not use a foreach loop container

    Rgds,

    See

    Rex Smith

  • Nope.

  • This link contains code for an Active X Script Task in DTS to do what you want. It shouldn't be too hard to put in a SSIS Script task.

    http://www.sqlservercentral.com/Forums/Topic444266-19-1.aspx

  • Hello,

    Both scripts are different. I need the VB.Net Script.

    Rgds,

    See

    Rex Smith

  • seeteshh (4/1/2010)


    Hello,

    Has anyone coded a script task that will upload 2 or more files to an FTP folder?

    I have done the same using a ForLoop and an FTP task but I need the code in a Script task that will not use a foreach loop container

    Rgds,

    Seetesh

    What's the point of this exercise?

    ---
    SSIS Tasks Components Scripts Services | http://www.cozyroc.com/

  • seeteshh (4/6/2010)


    Hello,

    Both scripts are different. I need the VB.Net Script.

    Rgds,

    Seetesh

    Is there a reason you can't use a for-each loop.

    doing this in .net is farily straight foward, start off by referencing System.Net and then use the FTP classes in there.

    http://msdn.microsoft.com/en-us/library/system.net.aspx"> http://msdn.microsoft.com/en-us/library/system.net.aspx

  • Our client has instructed to write script task where ftp password & other information is kept in some other files.

    Rex Smith

  • seeteshh (4/9/2010)


    Our client has instructed to write script task where ftp password & other information is kept in some other files.

    You can accomplish this without a need to write a script to FTP. You can write a script, which sets package variables and then use expressions to setup your FTP connection manager with the proper credentials information.

    ---
    SSIS Tasks Components Scripts Services | http://www.cozyroc.com/

  • Dim ssisFtp As FtpClientConnection

    Try

    'Now we create an SSIS connection for pulling the files:

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

    'Set the properties like username & password

    Dim intRetries As Int32 = Int32.Parse(Dts.Variables("FtpRetry").Value.ToString)

    ssisConn.Properties("ServerName").SetValue(ssisConn, Dts.Variables("ServerName").Value.ToString)

    ssisConn.Properties("ServerUserName").SetValue(ssisConn, Dts.Variables("FTPUser").Value.ToString)

    ssisConn.Properties("ServerPassword").SetValue(ssisConn, Dts.Variables("FTPPassword").Value.ToString)

    ssisConn.Properties("ServerPort").SetValue(ssisConn, Dts.Variables("ServerPort").Value.ToString)

    'The 0 setting will make it not timeout

    ssisConn.Properties("Timeout").SetValue(ssisConn, Dts.Variables("TimeOut").Value.ToString)

    ssisConn.Properties("ChunkSize").SetValue(ssisConn, Dts.Variables("ChunkSize").Value.ToString) '1000 kb

    ssisConn.Properties("Retries").SetValue(ssisConn, intRetries.ToString)

    'Next we create the FTP Connection

    ssisFtp = New FtpClientConnection(ssisConn.AcquireConnection(Nothing))

    'And we pass the modified file names in to retrieve the inflated files:

    ssisFtp.Connect()

    //Need to modify this code ********************

    Dim requiredFiles(2) As String

    requiredFiles(0) = "a.doc"

    requiredFiles(1) = "b.doc"

    // End - Need to modify this code *****************

    Dim intCount As Int32 = 0

    While (requiredFiles.Length > 0 OrElse (requiredFiles.Length = 1 AndAlso requiredFiles(0) <> "")) AndAlso intCount <= intRetries

    ssisFtp.SendFiles(requiredFiles, Dts.Variables("FtpDestination").Value.ToString, True, False)

    intCount += 1

    End While

    Need to work on the code postfix with ******

    Rex Smith

  • Any clues on this?

    Rex Smith

  • Has anyone used an array for files?

    Rex Smith

  • Hi Cozy/all,

    Can you post a sample snippet of script task reading data like userid/password/ipaddress from some flat file and using these as variables in the code.

    Instead of declaring environment variables.

    Rgds,

    Seetesh

    Rex Smith

  • use third party software like filezilla...

    😛

  • RexSmith (5/20/2010)


    Hi Cozy/all,

    Can you post a sample snippet of script task reading data like userid/password/ipaddress from some flat file and using these as variables in the code.

    Instead of declaring environment variables.

    Rgds,

    Seetesh

    You can use XML configuration file or SQL Table. There is no out-of-the-box setup from flat file.

    ---
    SSIS Tasks Components Scripts Services | http://www.cozyroc.com/

Viewing 14 posts - 1 through 13 (of 13 total)

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