ComponentSpace FTP Class Library Reference

FtpClientComponent Class

Wraps the FtpClient as a .NET component to expose the most commonly used properties and events at both design and run time.

For a list of all members of this type, see FtpClientComponent Members.

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         ComponentSpace.Ftp.FtpClientComponent

[Visual Basic]
Public Class FtpClientComponent
    Inherits Component
[C#]
public class FtpClientComponent : Component

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

The FTP connection may be established synchronously (blocking) using Connect, or asynchronously (non-blocking) using BeginConnect and EndConnect. All other potentially time consuming operations may either be performed synchronously or asynchronously.

The DataConnectionType property determines whether the data connection is outbound or inbound.

Optionally, the CommandSendTimeout and CommandReceiveTimeout may be set for the command connection.

Optionally, the DataSendTimeout and DataReceiveTimeout may be set for the data connection.

Example

This example connects to an FTP server, performs a download and then disconnects.

Dim ftpClientComponent As New FtpClientComponent()

' These properties can also be set at design time
ftpClientComponent.ServerAddress = "ftp.microsoft.com"
ftpClientComponent.UserName = "anonymous"
ftpClientComponent.Password = "me@mycompany.com"

ftpClientComponent.Connect()
                  
ftpClientComponent.Download("/Services/Museum/pictures/ballmerplunge.jpg", _
                            "c:\temp\ballmerplunge.jpg")
                              
ftpClientComponent.Disconnect()
You can also perform operations asynchronously. This example uses BeginConnect and EndConnect as well as BeginDownload and EndDownload and associated event handlers.
Dim ftpClientComponent As New FtpClientComponent()

' These events handlers can also be added at design time
AddHandler ftpClientComponent.ConnectCompleted, AddressOf OnConnectCompleted
AddHandler ftpClientComponent.DownloadCompleted, AddressOf OnDownloadCompleted

' These properties can also be set at design time
ftpClientComponent.ServerAddress = "ftp.microsoft.com"
ftpClientComponent.UserName = "anonymous"
ftpClientComponent.Password = "me@mycompany.com"

ftpClientComponent.BeginConnect()

Private Sub OnConnectCompleted(ByVal sender As Object, ByVal e As FtpOperationCompletedEventArgs)
    ftpClientComponent.EndConnect(e.AsyncResult)
    
    ftpClientComponent.BeginDownload("/Services/Museum/pictures/ballmerplunge.jpg", _
                                     "c:\temp\ballmerplunge.jpg")
                              
End Sub

Private Sub OnDownloadCompleted(ByVal sender As Object, ByVal e As FtpOperationCompletedEventArgs)
    ftpClientComponent.EndDownload(e.AsyncResult)
End Sub        

Requirements

Namespace: ComponentSpace.Ftp

Assembly: ComponentSpace.Ftp (in ComponentSpace.Ftp.dll)

See Also

FtpClientComponent Members | ComponentSpace.Ftp Namespace