Sends FTP requests and receives FTP responses using the File Transfer Protocol (RFC-959).
For a list of all members of this type, see FtpClient Members.
System.Object
ComponentSpace.Ftp.FtpClient
Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.
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.
Remote directory related actions are accessed through RemoteDirectory. Remote file related actions are accessed through RemoteFile. Multi-file actions are accessed through MultiFile.
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.
This simple download example uses the Download static method of the FtpClient class. It will connect, download and disconnect in a single method call.
FtpClient.Download("ftp.microsoft.com", _
"anonymous", _
"me@mycompany.com", _
TransferMode.Binary, _
"/Services/Museum/pictures/ballmerplunge.jpg", _
"c:\temp\ballmerplunge.jpg")
Alternatively you can connect, perform multiple operations and then disconnect. Dim ftpClient As New FtpClient()
ftpClient.Connect("ftp.microsoft.com", _
"anonymous", _
"me@mycompany.com")
ftpClient.RemoteFile.Download("/Services/Museum/pictures/ballmerplunge.jpg", _
"c:\temp\ballmerplunge.jpg")
' Perform other FTP commands against this server
ftpClient.Disconnect()
Finally, you can perform all operations asynchronously. This example uses RemoteFile.BeginDownload and RemoteFile.EndDownload and an event handler. Dim ftpClient As New FtpClient()
ftpClient.Connect("ftp.microsoft.com", _
"anonymous", _
"me@mycompany.com")
AddHandler ftpClient.RemoteFile.DownloadCompleted, AddressOf OnDownloadCompleted
ftpClient.RemoteFile.BeginDownload("/Services/Museum/pictures/ballmerplunge.jpg", _
"c:\temp\ballmerplunge.jpg")
Private Sub OnDownloadCompleted(ByVal sender As Object, ByVal e As FtpOperationCompletedEventArgs)
ftpClient.RemoteFile.EndDownload(e.AsyncResult)
End Sub
Namespace: ComponentSpace.Ftp
Assembly: ComponentSpace.Ftp (in ComponentSpace.Ftp.dll)