locked
FTP TASK RRS feed

  • Question

  • i HAVE ftp location.

     

    I want to found out is there any file in ftp location, goto to next step file is not there stop the package.

     

    can we do it WITH FTP TASK.

     

     

     

    Sunday, February 5, 2012 7:12 AM

Answers

  • 1) You could use a Script Task to find out if there are any files.

                    // Get the ftp connection from the Connection Managers collection 
                    ConnectionManager ftpServer = Dts.Connections["myFtpServer"]; 
      
                    // Create a FTP connection object and us the credentials of connection manager 
                    FtpClientConnection myFtpConnection = new FtpClientConnection(ftpServer.AcquireConnection(null)); 
      
                    // Open the connection 
                    myFtpConnection.Connect(); 
      
                    // Set work folder with the value of the variable 
                    myFtpConnection.SetWorkingDirectory(Dts.Variables["FtpWorkingDirectory"].Value.ToString()); 
      
                    // Create StringArrays for filenames and folders 
                    // The folderNames aren't used, but is mandatory 
                    // for the next method. 
                    String[] fileNames; 
                    String[] folderNames; 
      
                    // Get a directory listing and fill the StringArray variables 
                    myFtpConnection.GetListing(out folderNames, out fileNames); 
    
    

    Now fileNames.Length will give you the number of files in the folder.

    2) You could just download all files in the folder.... followed by a foreach loop. If there aren't files the foreach loop won't find anything.
    3) You could use a Custom Foreach FTP File Enumerator/Loop to loop through the ftp folder.


    Please mark the post as answered if it answers your question | My SSIS Blog: http://microsoft-ssis.blogspot.com
    • Proposed as answer by Eileen Zhao Tuesday, February 7, 2012 8:36 AM
    • Marked as answer by Eileen Zhao Friday, February 10, 2012 12:26 AM
    Sunday, February 5, 2012 8:53 AM

All replies

  • What do you want to do? Receive files, send files? 

    http://www.youtube.com/watch?v=CpTmgZgWgH0


    Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/
    Sunday, February 5, 2012 8:30 AM
  • 1) You could use a Script Task to find out if there are any files.

                    // Get the ftp connection from the Connection Managers collection 
                    ConnectionManager ftpServer = Dts.Connections["myFtpServer"]; 
      
                    // Create a FTP connection object and us the credentials of connection manager 
                    FtpClientConnection myFtpConnection = new FtpClientConnection(ftpServer.AcquireConnection(null)); 
      
                    // Open the connection 
                    myFtpConnection.Connect(); 
      
                    // Set work folder with the value of the variable 
                    myFtpConnection.SetWorkingDirectory(Dts.Variables["FtpWorkingDirectory"].Value.ToString()); 
      
                    // Create StringArrays for filenames and folders 
                    // The folderNames aren't used, but is mandatory 
                    // for the next method. 
                    String[] fileNames; 
                    String[] folderNames; 
      
                    // Get a directory listing and fill the StringArray variables 
                    myFtpConnection.GetListing(out folderNames, out fileNames); 
    
    

    Now fileNames.Length will give you the number of files in the folder.

    2) You could just download all files in the folder.... followed by a foreach loop. If there aren't files the foreach loop won't find anything.
    3) You could use a Custom Foreach FTP File Enumerator/Loop to loop through the ftp folder.


    Please mark the post as answered if it answers your question | My SSIS Blog: http://microsoft-ssis.blogspot.com
    • Proposed as answer by Eileen Zhao Tuesday, February 7, 2012 8:36 AM
    • Marked as answer by Eileen Zhao Friday, February 10, 2012 12:26 AM
    Sunday, February 5, 2012 8:53 AM
  • Suresh,

    Using FTP Task, you cannot check whether the rempte location has any file(s).

    You need to prepare the remote location(make sure that data exists on remote server) and only then initiate a remote connection.

    Have you considered using a script task?


    Please vote as helpful or mark as answer, if it helps
    Cheers, Raunak | t: @raunakjhawar | My Blog
    Monday, February 6, 2012 5:58 AM