Welcome to the Xceed Community | Help
Community Search  
More Search Options

List all files on Ftp-Server

Sort Posts: Previous Next
  •  12-27-2008, 4:45 PM Post no. 17646

    List all files on Ftp-Server



    how can i list all files on a ftp-server?

    include sub-folders...



  •  12-29-2008, 2:42 PM Post no. 17652 in reply to 17646

    Re: List all files on Ftp-Server

    Hi Thorsten,

    you could use the method GetFiles (http://doc.xceedsoft.com/products/XceedFileSystem/Xceed.FileSystem~Xceed.FileSystem.AbstractFolder~GetFiles(Boolean,Object[]).html) of the AbstractFolder with the Boolean recursive  parameter set to true in order to get the list of all files on the FTP server including the sub folders.

    For instance, you could modify the code snippet of Xceed Software samples as follow:

    using( FtpConnection connection = new FtpConnection( hostname ) )


    // You can begin with the starting folder by using the FtpFolder

    // constructor that only takes an FtpConnection.

    AbstractFolder rootFolder = new FtpFolder( connection );


    Console.WriteLine( "The starting folder on {0} is '{1}'.",

    hostname, rootFolder.FullName );


    // You can access subfolders by asking any folder for a relative name

    AbstractFolder firstFolder = rootFolder.GetFolder( firstRelativePath );


    Console.WriteLine( "You are now in '{0}'.", firstFolder.FullName );


    AbstractFolder secondFolder = firstFolder.GetFolder( secondRelativePath );

    Console.WriteLine( "And now in '{0}'.", secondFolder.FullName );

    // When you know the exact full path of a folder, you can directly create

    // a new FtpFolder with that path.

    AbstractFolder absoluteFolder = new FtpFolder( connection, absolutePath );


    Console.WriteLine( "And finally in '{0}'.", absoluteFolder.FullName );


    // Very important: Though we just created many instances accessing

    // different folders on this FTP server, the FTP FileSystem hides the

    // complexity of remembering the "current folder", as you need to do

    // when using a client-style interface. As you can see, each and every

    // instance created above are fully accessible.

    Console.WriteLine( "*** rootFolder variable ***" );


    foreach( FileSystemItem item in rootFolder.GetFiles(true) )


    Console.WriteLine( " {0}", item.FullName );




    Xceed - Software Developer and Technical Support
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.