VB example Delphi example C# example VB.NET example
There are two ways of using the XceedFtp control to obtain the listing of a remote folder's contents. The first way is to use the ListFolderContents method, which will cause the ListingFolderItem event to be triggered for each item in the remote folder, thus providing your application with information on each item separately. The second way is to use the GetFolderContents method, which returns an XceedFtpFolderItems collection object that contains the directory listing items. The second method is preferable in environments such as ASP pages which do not support events.
This topic describes the ListFolderContents method. See the Getting a remote folder's contents topic for help with the GetFolderContents method.
To list the files on an FTP server, you need to perform the following steps. Put an XceedFtp control on a form, or instantiate it dynamically, then:
Specify the FTP server address to connect to. To do this, set the ServerAddress property.
Specify the username to login. Use the UserName property, which is 'Anynomous' by default.
Specify the username's password. Use the Password property, which is 'guest' by default.
Connect to the specified host. To do this, call the Connect method.
Begin the listing of the remote folder. To do this, call the ListFolderContents method.
Process each item being listed. Write a handler for the ListingFolderItem event.
Disconnect from the FTP server. Do this by calling the Disconnect method.
Make sure that everything worked properly. To do this, use your language's error handling object or error handling capabilities. The Xceed FTP Library supports standard COM error handling functionality.
You can obtain the current working folder by checking the value of the CurrentFolder property.
While you are connected, you can perform as many send, receive, listing or other FTP commands as needed.
Is the FTP server listening on a port other than the usual TCP/IP port 21? If yes, then set the ServerPort property.
The FTP protocol supports "Accounts". Does your FTP server require you to specify an account? If yes, then set the AccountName property or write a handler for the AccountRequired event.