Delete Remote Files With FTP Task

  • I have a sequence with two FTP Tasks; one to retrieve a file from an FTP server, the other to delete the file from the FTP server.  I use the same connection manager for both tasks.  The remote path is in a variable and used for both tasks.  The retrieve works just fine.  The problem is that the delete task fails with the error:

    Error: 0xC002918E at FTP Task, FTP Task: Unable to delete remote files using "FTP Connection Manager 1".

    I can use FTP on a commandline to delete the files so I don't think it's a problem with permissions.

  • I have exactly the same problem. Did you ever find a solution?

  • try this post on another forum:

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1074276&SiteID=1

  • [font="Comic Sans MS"]Try use different connection manager for delete purpose

    Are you running the package as a job or from BIDS?

    In the connection manager have you specified correct username and password that is having privilege on the FTP destination?[/font]

  • Turns out that this is a known issue if the FTP server is Unix-based.

  • Yes, I did try with a separate connection manager and my user name and password were correct.

    What I ended up doing was to create a Script task. I also created variables ftpServerName, ftpPath, ftpUserName, ftpPassword to hold my connection properties and passed them as read only variables to the script task. Here is the code for this script task. This works for me.

    Public Sub Main()

    Dim ftpServerName As String = CStr(Dts.Variables("ftpServerName").Value)

    Dim ftpPath As String = CStr(Dts.Variables("ftpPath").Value)

    Dim ftpUserName As String = CStr(Dts.Variables("ftpUserName").Value)

    Dim ftpPassword As String = CStr(Dts.Variables("ftpPassword").Value)

    Dim strFTPScriptFileName As String

    Dim objMyFile As Object

    Dim objFSO As Object

    strFTPScriptFileName = "c:\FtpDeleteTemp"

    objFSO = CreateObject("Scripting.FileSystemObject")

    If (objFSO.FileExists(strFTPScriptFileName)) Then

    objFSO.DeleteFile(strFTPScriptFileName)

    End If

    objMyFile = objFSO.CreateTextFile(strFTPScriptFileName, True)

    objMyFile.WriteLine("open " & ftpServerName)

    objMyFile.WriteLine(ftpUserName)

    objMyFile.WriteLine(ftpPassword)

    objMyFile.WriteLine("cd " & ftpPath)

    objMyFile.WriteLine("prompt ") 'toggle off prompting

    objMyFile.WriteLine("mdelete *.* ")

    objMyFile.WriteLine("bye")

    objMyFile.WriteLine("pause")

    objMyFile.Close()

    objFSO = Nothing

    objMyFile = Nothing

    'The following code executes the FTP script. It creates a Shell

    'object and run FTP program on top of it.

    Dim objShell As Object

    objShell = CreateObject("WScript.Shell")

    objShell.Run("ftp -s:" & Chr(34) & strFTPScriptFileName & Chr(34))

    objShell = Nothing

    Dts.TaskResult = Dts.Results.Success

    End Sub

  • My work around wasn't elegent, but I ended up using .txt files and running the ftp executable.

  • thank you. I am also facing similar issues while deleting files using the FTP Task in SSIS.

    Shame that even today, Microsoft didn't come out with a fix !

Viewing 8 posts - 1 through 7 (of 7 total)

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