VB example Delphi example Visual C++ ATL 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 GetFolderContents method. See the Listing a remote folder's contents topic for help with the ListFolderContents 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.
Obtain the directory listing object. To do this, call the GetFolderContents method.
Disconnect from the FTP server. Do this by calling the Disconnect method.
Process the listed items. Use the XceedFtpFolderItems collection object obtained from the GetFolderContents method to iterate through the items.
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.