Copy file to ftp in Script Task

  • All, 🙁

    Need help for the following. I need to be able to copy a file to Vendor's FTP on weekly basic.

    I have the following in my Script Task.Upon execution it returns ArgumentException [xxx.com/123/Files/File1.zip'is not a valid remote file address. A valid address should include a protocol, a path and a file name]

    Here is what I have in my Script Task

    Dim server As String = "//ftp://xxx.com/123/Files/"

    Dim User As String = "User1"

    Dim Password As String = "Password1"

    Dim remoteFTP As String = server & System.IO.Path.GetFileName(file.FullName)

    My.Computer.Network.UploadFile(file.FullName, remoteFTP, User, Password, True, 500)

    While Debugging the remoteFTP string displays

    = "//ftp://xxx.com/123/Files/File1.zip"

    I've nvr copied a file to a ftp before.Therfore Im not sure if this code is even correct.Ive got it from http://social.msdn.microsoft.com/forums/en-US/vblanguage/thread/7945dbd9-5836-4eaa-b8fe-32ad70002e43.

    Appreciate if someone could help me out. Thank You.

    Im just soo stuck on this piece.

  • Tried changing

    Dim server As String = "//ftp://xxx.com/123/Files/"

    to

    Dim server As String = "ftp://xxx.com/123/Files/"

    and I get the following Exception

    The remote server returned an error: (550) File unavailable (e.g., file not found, no access).

  • Anybody out there used this before ?:sick:

    I need to get this done with.

  • Have you tried using the FTP Task or do you need to use a Script Task for some reason?

    I've never used it before but it may solve your issue.

  • Hi Paul,

    Im thinking to use FTP Task now,Do you have any ideas on how I can

    only send files that have todays date in it to the Vendor.

    File names are similar to this format AA09182008.zip.There are 6 file in total,all file name's have todays date in [mmddyyyy] in it.

    Appreciate your help!Thanks

  • You will need to loop through all the files and send them one by one (unless there is a bulk send option somewhere that I haven't heard of) so I guess you can have a script task up front (before the loop) that gets all the files you are after into a collection. Then you can loop through them and set the source file connection settings are necessary and feed that into the ftp task.

  • You mean to say have a script task to get files with todays date.Store the file names in a location.Put a FTP task in a for loop and loop through all the files to the FTP Task by passing the file name as a variable.I will try this tom.Do let me know if this is correct?

  • Yeah but I'm not sure if you can simply pass the filename as a variable to the FTP Task. I think the FTP Task will expect a source file connection manager, so you may need to set the file path variable in the connection manager.

  • I shall try tom and update my doubts.Thank You.

  • I solved it using this

    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=110841

  • LOOKUP_BI (9/25/2008)


    I solved it using this

    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=110841%5B/quote%5D

    He meant this 😛 (saves you guys a click)

    How to: Upload Files with FTP

    SQLServerNewbieMCITP: Database Administrator SQL Server 2005

Viewing 11 posts - 1 through 10 (of 10 total)

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