Version: 3.0.2.0
Add comprehensive secure file transfer capabilities to any .NET application.

Ftp .NET Component

The Ftp component is a powerful and flexible component-based implementation of the File Transfer Protocol (with security extentions). High-level properties and methods provide quick code creation and ease-of use, while access to lower-level properties and methods provide power and control. Here are some feature highlights:

  • Authenticates and encrypts/decrypts transferred data using SSL2, SSL3, PCT or TLS. Non-secure mode is used when privacy is not required.
  • Transfers multiple files, including directory trees, with a single line of code. Also, deletes directory trees with a single line.
  • Optionally pipelines file data by providing direct stream access to the data connection.
  • Supports both asynchronous (event-driven) and synchronous (scripted) application designs.
  • Supports explicit and implicit SSL, with secure or clear data connections.
  • Resumes interrupted transfers, and aborts transfers without losing the session connection.
  • Supports large file transfers, with sizes greater than 4 GB.
  • Progress event reports data sent and received in real-time.
  • Automatically parses listings into easy-to-use objects.
  • Performs ASCII or Binary transfers, in both Passive and Active modes.
  • Any custom command can be sent to the server.
  • Creates and deletes folders on the server.
  • Trace event provides access to the underlying communication, making logging and debugging sessions easy.
  • Transfers files through all common firewalls and proxies, including Socks 4/5, Ftp SITE, Ftp USER, Ftp OPEN, Http CONNECT, and more. Transfers files securely from behind Network Address Translating (NAT) routers.
  • Can be used to create traditional client applications and services, as well as scalable server-based ASP.NET applications.
  • Customizable certificate authentication provides complete control over what is accepted or rejected from the server. Client certificates are also supported.
  • CertificateStore class interfaces with certificates in Microsoft Certificate Stores, or simply loads exported certificate files from disk.

Looking for the ActiveX version of this component?

Interface

Public Constructors
Ftp Overloaded. Initialize a new instance of the Ftp class.
Public Properties
Account Gets or sets account information required by the server. Not normally used.
Allocate Gets or sets a value that controls the use of the ALLO command before files are stored on the server.
BlockSize Gets or sets the buffer size used during file and socket I/O.
Busy Returns true if a method is currently in use.
Certificate The Certificate object representing the certificate to use for optional client-side authentication.
Client Gets or sets the client hostname or address when a specific interface binding is desired.
ClientDataPort Gets or sets a string used to restrict the local data port to a value or range compatible with your firewall.
ClientPort

Gets or sets a string used to restrict the local data port to a value or range of values.

Compression Gets or sets the type of compression desired (None, Archive, or Full).
Connected Gets the connected state of the connection.
Connection Gets the Tcp component instance used for the connection.
DoEvents Gets or sets a value that controls the processing of events during blocking method calls.
Editor In Visual Studio.NET, displays an interactive form to use to test real time protocol operations.
FileType Gets or sets the data type for subsequent transfers.
MaxTransferRate Gets or sets a value that can be used to throttle the file transfer rate.
Passive Gets or sets a value that determines if the server should accept a passive data connection.
Password Gets or sets the password used during session login.
ProgressSize Gets or sets a value that controls how often the Progress event is raised.
Proxy Returns the FtpProxy instance that controls proxy server use.
Restart Gets or sets a value that controls the automatic use of file transfer restarts.
Security Specifies the security protocol and authentication type used.
Server Gets or sets the FTP server hostname or address.
ServerPort Gets or sets the FTP server port.
StoreType Gets or sets the type of store to use when the Ftp.Put method or Ftp.BeginPut method is called.
SynchronizingObject Set this object to automatically control thread marshalling between worker threads and the main UI thread.
Timeout Specifies the maximum number of milliseconds to wait for responses to commands or time between data buffer transfers.
UseAuthentication Gets or sets a value that determines if certificate authentication is used.
UseControlAddressForPassive Gets or sets a value that determines what server address should be used when making a passive data connection.
UseIpSync Gets or sets a value that controls the use of the SYNC signal when aborting a transfer.
Username Gets or sets the Ftp.Username used during session login.
UseSslShutdown

Gets or sets a value that controls the use of SSL shutdown signalling.

Public Methods
Abort Abruptly close both the control and data connection.
AbortTransfer Abort the current file transfer operation.
BeginDelete Deletes a file or directory tree asynchronously.
BeginGet Overloaded. Get a single file from the server asynchronously and store it in a local file.
BeginInvoke Invoke an FTP command (with a parameter) asynchronously.
BeginList Get a file listing from the server asynchronously.
BeginPut Overloaded. Put multiple files to the server asynchronously and store them in the root specified.
Close Wait for all activity to complete and gracefully close the control connection.
Delete Deletes a file or directory tree synchronously.
ExpandLocalFiles Gets a string array of local file pathnames that match the wildcard search pattern.
ExpandRemoteFiles Gets a string array of remote file pathnames that match the wildcard search pattern.
Get Overloaded. Get a single file from the server synchronously.
GetDirectory Gets the server's working directory.
GetSize Gets the size of any file.
Invoke Overloaded. Send an FTP command (with a command modifier) synchronously.
List Retrieve a file listing from the server synchronously.
Put Overloaded. Store a single file to the server synchronously.
RawConnect Optional method you can use if you need to connect to an FTP server that expects a login seqence that is non-standard.
Rename Rename a file on the server.
SendCommand Send any command to the server.
Public Events
BusyChanged Raised when the value of the Object.Busy property changes.
CertificateReceived Raised when a certificate has been received to be authenticated.
CertificateRequested Raised when a certificate has been requested.
ConnectedChanged Raised when the value of the Object.Connected property changes.
EndDelete Raised when the Ftp.BeginDelete request completes.
EndGet Raised when the Ftp.BeginGet request completes.
EndInvoke Raised when the Ftp.BeginInvoke request completes.
EndList Raised when the Ftp.BeginList request completes.
EndPut Raised when the Ftp.BeginPut request completes.
Progress Raised repeatedly while a file transfer is in progress.
Trace Raised when data has been sent/received.

Code Example

How easy is it to use the Ftp component? The following example demonstrates transferring files securely.

VB.NET Example
Private Sub SecureTest()
   ' Set the server & user info
   Ftp1.Server = "myftpserver"
   Ftp1.ServerPort = 21
   Ftp1.Username = "user"
   Ftp1.Password = "pass"

   ' "Enable" certificate authentication (verify any certificate the server sends)
   Ftp1.UseAuthentication = True

   ' Set the desired security/authentication to explicit. 
   Ftp1.Security = Dart.PowerTCP.SecureFtp.Security.Explicit

   ' Execute a command (this will cause an SSL connection to be made first
   ' and the data will be sent securely)
   Dim dir As String = Ftp1.GetDirectory()
   Debug.WriteLine("Current directory: " + dir)

   ' Close the connection.
   Ftp1.Close()
End Sub

Private Sub Ftp1_CertificateReceived(ByVal sender As Object, e As _
Dart.PowerTCP.SecureFtp.CertificateReceivedEventArgs) Handles Ftp1.CertificateReceived
   Dim msg As String = ""

   ' Check to see if the certificate is from a trusted root.
   If Not e.TrustedRoot Then
      msg += "This certificate is not from a trusted root" + vbCrLf
   End If

   ' Check to see if the certificate has a valid date.
   If Not e.ValidDate Then
      msg += "This certificate does not have a valid date" + vbCrLf
   End If

   ' Check to see if the certificate has a valid name.
   If Not e.ValidName Then
      msg += "This certificate does not have a valid name" + vbCrLf
   End If
   
   If msg <> "" Then
      msg += "Would you like to accept this certificate anyway?"
      If MessageBox.Show(msg, "Invalid Cert Received", MessageBoxButtons.YesNo)_
       = DialogResult.Yes Then
         ' User wants to accept the invalid cert. Accept it.
         e.Accept = True
      End If
   End If
End Sub