This topic demonstrates how to list contents on an FTP server using the static GetFtpContents method of the QuickFtp class.
GetFtpContents method
The GetFtpContents method has various overloads that can be used to list the contents of a server. Some only require that you specify the hostname, the local destination folder, and the files to receive, while others provide options such as using a username and password, port numbers, authentication, whether to replace existing files, preserve paths, proxies, passive transfers, synchronizing objects, etc. For details on the other overloads, see the reference documentation.
Basic steps
To list contents on an FTP server, the following steps must be performed:
-
Declare an array of QuickFtpItem objects that will contain the result of the call to the GetFtpContents method.
-
Iterate through the array of QuickFtpItem objects to retrieve information on each QuickFtpItem object it contains.
Demonstration
In the following example, we specify the hostname, a port number, a username and a password, the remote folder to list, whether or not to get the list recursively, and a filter.
VB.NET | Copy Code |
---|---|
|
C# | Copy Code |
---|---|
|
Things you should consider
The main questions you should ask yourself when listing contents on an FTP server are:
-
Do you want to do more complex FTP operations? Use the FileSystem-based classes defined within the Xceed.Ftp namespace.