The Proxy property and the HttpProxyClient class are used to connect to an FTP server through an HTTP proxy. Once the Proxy property has been set with an HttpProxyClient object, regular FileSystem FTP operations can be performed. The Proxy property cannot be changed once a connection has been made to the FTP server. Note that only HTTP proxy servers are currently supported. Furthermore, there is no need to use the proxy capabilities when connecting through a transparent proxy server.
The following examples demonstrate how to connect to an FTP server through an HTTP proxy server using the steps listed below:
Create an instance of the FtpConnection class for the connection between the client and the FTP server. If you are using FtpConnection in a UI application, assign your form (or any other control that implements the ISynchronizeInvoke interface) to the SynchronizingObject property and call Application.DoEvents in an event such as ByteProgression.
Assign an HttpProxyClient object to the FtpConnection's Proxy property.
Perform any FileSystem-based operations you wish, such as transferring files and folders to or from the FTP server, compressing or uncompressing them, encrypting or decrypting them, using them with memory-based operations, etc. The code below downloads a folder to the local computer. For more details on how to perform this operation, see the next topic, How to copy items from an FTP server (download).
Dispose of the FtpConnection once the operation is completed by calling its Dispose method or, in C#, by creating the FtpConnection instance in a using block. If an instance of an FtpConnection object is not disposed of, connections with the FTP server may remain active until the FTP server times-out or the garbage-collector passes.
VB.NET | Copy Code |
---|---|
|
C# | Copy Code |
---|---|
using Xceed.FileSystem; |