FTP script task using connection on SSIS

  • Hi,

    under the script that I use for upload file using SSIS asp.net task.

    My problem....

    If I comment this line

    'ftp.SendFiles(files, "", True, False) ' the True makes it overwrite existing

    upload made successfull without failure instead If I leave uncomment I got an error but files upload anyway correct.

    Someone can give me some explains about this behavior?

    TNKS Alen, Italy

    ------------------

    Public Sub Main()

    'Create the connection to the ftp server

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

    'create the FTP object that sends the files and pass it the connection created above.

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

    Try

    'Set the properties like username & password

    cm.Properties("ServerName").SetValue(cm, "xxxxxx")

    cm.Properties("ServerUserName").SetValue(cm, "xxxxx")

    cm.Properties("ServerPassword").SetValue(cm, "xxxxx")

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

    cm.Properties("Timeout").SetValue(cm, "0") 'The 0 setting will make it not timeout

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

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

    'Connects to the ftp server

    http://ftp.Connect()

    '****************************************

    ' Potrebbe servire in futuro la tengo

    '****************************************

    ''Get file listing

    'Dim fileNames() As String

    'Dim folderNames() As String

    'ftp.GetListing(folderNames, fileNames)

    ''ftp the files

    'ftp.DeleteFiles(fileNames)

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

    Dim files(1) As String

    files(0) = "\\manny-slave\appWork\FACT-FINDER\a.txt"

    files(1) = "\\manny-slave\appWork\FACT-FINDER\b.txt"

    'ftp the file

    'I found it by mistake by creating both the FTP connection and task in the SSIS package and it defaulted the remote path setting in the FTP task.

    'ftp.SendFiles(files, "", True, False) ' the True makes it overwrite existing file and False is saying that it is not transferring ASCII

    http://ftp.Close()

    Dts.TaskResult = Dts.Results.Success

    Catch ex As Exception

    http://ftp.Close()

    Dts.TaskResult = Dts.Results.Failure

    Finally

    http://ftp.Close()

    End Try

    End Sub

  • So please correct me if I do not understand.

    If your code looks like that:

    files(0) = "\\manny-slave\appWork\FACT-FINDER\a.txt"

    files(1) = "\\manny-slave\appWork\FACT-FINDER\b.txt"

    http://ftp.SendFiles(files, "", True, False)

    http://ftp.Close()

    then it rise error?

    What is the error message?

    But if your code looks like that:

    files(0) = "\\manny-slave\appWork\FACT-FINDER\a.txt"

    files(1) = "\\manny-slave\appWork\FACT-FINDER\b.txt"

    http://ftp.Close()

    then there is no error and files are placed on the ftp server?

    Did you check that a.txt and b.txt files does not exists on the ftp server before run the second code?

  • OK, now work...this is the rigth codes.

    Tnks for support anyway...

    use Directory.GetFiles() for my array of string file.

    http://ftp.SendFiles(Directory.GetFiles(strPathDirectoryLocal & "\" & strNomeCartella), "/imports/SSIS/" & strNomeCartella, True, False)

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

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