'Declaration Public Class AsyncFtpClient Inherits FtpClient
'Usage Dim instance As AsyncFtpClient
public class AsyncFtpClient : FtpClient
AsyncFtpClient's methods now call the corresponding synchronous methods on a background thread. It is therefore recommended to use FtpClient and assign a SynchronizingObject to its SynchronizingObject property to improve code readability. For this reason, the AsyncFtpClient class is now considered obsolete.
This class provides you the with same functionalities that you will find in the FtpClient class but also gives you access to asynchronous FTP functionalities.
'Declaration Public Class AsyncFtpClient Inherits FtpClient
'Usage Dim instance As AsyncFtpClient
public class AsyncFtpClient : FtpClient
Xceed FTP for .NET is a highly multi-threaded library that uses asynchronous operations on sockets and network streams to allow fast and robust execution. This results in most events being called from a different thread than the one that called the initiating method.
When building a GUI application using System.Windows.Forms, UI elements (controls and forms) must always be accessed from the main thread since they have thread-affinity for the main STA thread. This is done using Control.Invoke or Control.BeginInvoke.
To avoid the need to call Control.Invoke or Control.BeginInvoke, the FtpClient.SynchronizingObject property can be set to any object implementing the System.ComponentModel.ISynchronizeInvoke interface. In doing so, the library will take care of raising the events on the thread of that object.
In order to avoid cross-blocking calls, the library will call System.Windows.Forms.Application.DoEvents to pump the messages on the main thread when using blocking methods. When using the asynchronous methods, the library will not pump messages for you. When using a callback, there is no need to pump the messages since the execution is not blocked. When waiting for the completion of the operation, messages must be pumped manually by calling System.Windows.Forms.Application.DoEvents.
Dim client As New AsyncFtpClient() ' You can instruct the library to automatically redirect events on the main UI thread ' by setting the SynchronizingObject property. client.SynchronizingObject = m_resultForm Try ' Start connecting asynchronously. client.BeginConnect("ftp.winzip.com", New AsyncCallback(AddressOf ConnectCompleted), client) Catch except As Exception Console.WriteLine(except.Message) End Try Private Sub ConnectCompleted(result As IAsyncResult) Dim client As AsyncFtpClient = result.AsyncState Try ' All Begin calls must be matched by their End call. client.EndConnect(result) ' Now that we are connected, let's login anonymously, but again ' using the async method call. client.BeginLogin(New AsyncCallback(AddressOf LoginCompleted), client) Catch except As Exception Console.WriteLine(except.Message) End Try End Sub Private Sub LoginCompleted(result As IAsyncResult) Dim client As AsyncFtpClient = result.AsyncState Try ' All Begin calls must be matched by their End call. client.EndLogin(result) ' Finally, we disconnect asynchronously. You can see that if you ' wish to perform more operations, a cascading series of async ' calls can get out of hand. client.BeginDisconnect(New AsyncCallback(AddressOf DisconnectCompleted), client) Catch except As Exception Console.WriteLine(except.Message) End Try End Sub Private Sub DisconnectCompleted(result As IAsyncResult) Dim client As AsyncFtpClient = result.AsyncState Try ' All Begin calls must be matched by their End call. client.EndDisconnect(result) Catch except As Exception Console.WriteLine(except.Message) End Try End Sub
AsyncFtpClient client = new AsyncFtpClient(); // When using the AsyncFtpClient class, you can instruct // the library to automatically redirect events on the main UI thread // by setting the SynchronizingObject property. client.SynchronizingObject = m_resultForm; try { // Start connecting asynchronously. IAsyncResult result = client.BeginConnect( hostname, new AsyncCallback( ConnectCompleted ), client ); } catch( Exception except ) { console.WriteLine( except.Message ); } private void ConnectCompleted( IAsyncResult result ) { AsyncFtpClient client = result.AsyncState as AsyncFtpClient; try { // All Begin calls must be matched by their End call. client.EndConnect( result ); // Now that we are connected, let's login anonymously, but again using the async method call. client.BeginLogin( new AsyncCallback( LoginCompleted ), client ); } catch( Exception except ) { Console.WriteLine( except.Message ); } } private void LoginCompleted( IAsyncResult result ) { AsyncFtpClient client = result.AsyncState as AsyncFtpClient; try { // All Begin calls must be matched by their End call. client.EndLogin( result ); // Finally, we disconnect asynchronously. You can see that if you // wish to perform more operations, a cascading series of async // calls can get out of hand. client.BeginDisconnect( new AsyncCallback( DisconnectCompleted ), client ); } catch( Exception except ) { Console.WriteLine( except.Message ); } } private void DisconnectCompleted( IAsyncResult result ) { AsyncFtpClient client = result.AsyncState as AsyncFtpClient; try { // All Begin calls must be matched by their End call. client.EndDisconnect( result ); } catch( Exception except ) { Console.WriteLine( except.Message ); } }
' If you don't mind pumping messages explicitly, this alternative ' use of AsyncFtpClient can prove very useful to get readable code. Dim client As New AsyncFtpClient() ' You can instruct the library to automatically redirect events on the main UI thread ' by setting the SynchronizingObject property. client.SynchronizingObject = m_resultForm Try ' Start connecting asynchronously. No need for a callback! Dim result As IAsyncResult = client.BeginConnect(hostname, Nothing, Nothing) ' Wait for that async result to complete, making sure to pump messages. While Not result.IsCompleted Application.DoEvents() End While ' Complete the connection. All "Begin" calls must be matched ' by their matching "End" method call. client.EndConnect(result) ' Now that we are connected, we can login. result = client.BeginLogin(Nothing, Nothing) While Not result.IsCompleted Application.DoEvents() End While client.EndLogin(result) ' And finally, we disconnect. result = client.BeginDisconnect(Nothing, Nothing) While Not result.IsCompleted Application.DoEvents() End While client.EndDisconnect(result) Catch except As Exception Console.WriteLine(except.Message) End Try
AsyncFtpClient client = new AsyncFtpClient(); // When using the AsyncFtpClient class, you can instruct // the library to automatically redirect events on the main UI thread // by setting the SynchronizingObject property. client.SynchronizingObject = m_resultsForm; try { // Start connecting asynchronously. No need for a callback! IAsyncResult result = client.BeginConnect( hostname, null, null ); // Wait for that async result to complete, making sure to pump messages. while( !result.IsCompleted ) Application.DoEvents(); // Complete the connection. All "Begin" calls must be matched by their matching "End" method call. client.EndConnect( result ); // Now that we are connected, we can login. result = client.BeginLogin( null, null ); while( !result.IsCompleted ) Application.DoEvents(); client.EndLogin( result ); // And finally, we disconnect. result = client.BeginDisconnect( null, null ); while( !result.IsCompleted ) Application.DoEvents(); client.EndDisconnect( result ); } catch( Exception except ) { Console.WriteLine( except.Message ); }
System.Object
Xceed.Ftp.FtpClient
Xceed.Ftp.AsyncFtpClient
Name | Description | |
---|---|---|
![]() | AsyncFtpClient Constructor | Initializes a new instance of the AsyncFtpClient class. |
Name | Description | |
---|---|---|
![]() | m_rawExtendedFeatureCache | (Inherited from Xceed.Ftp.FtpClient) |
Name | Description | |
---|---|---|
![]() | ActiveSecurityOptions | (Inherited from Xceed.Ftp.FtpClient) |
![]() | Busy | Gets a boolean value indicating if the FTP client is currently performing an FTP operation. For detailed state information, consult the FtpClient.State property. (Inherited from Xceed.Ftp.FtpClient) |
![]() | Connected | Gets a boolean value indicating if the FTP client is connected to an FTP server. For detailed state information, consult the FtpClient.State property. (Inherited from Xceed.Ftp.FtpClient) |
![]() | DataChannelProtection | (Inherited from Xceed.Ftp.FtpClient) |
![]() | Encoding | Gets or sets the System.Text.Encoding that is used to encode commands sent to the server, and decode replies and folder listings received from the server. (Inherited from Xceed.Ftp.FtpClient) |
![]() | FxpPassiveTransfer | Gets or sets a Boolean value indicating if FXP file transfers use the passive method or not to initiate the data connection. (Inherited from Xceed.Ftp.FtpClient) |
![]() | HostName | Gets the host name used to connect, or an empty string if not connected. (Inherited from Xceed.Ftp.FtpClient) |
![]() | KeepAliveInterval | Gets or sets the interval, in seconds, at which a NOOP command is sent on the command channel during a file transfer. (Inherited from Xceed.Ftp.FtpClient) |
![]() | ListingMethod | Gets the current listing method that is used to retrieve folder contents from the FTP server. (Inherited from Xceed.Ftp.FtpClient) |
![]() | ListingParsers | Gets a collection of FtpListingParser objects that are used to parse the lines returned by calls to various methods. (Inherited from Xceed.Ftp.FtpClient) |
![]() | LocalAddress | Gets or sets the local IP address and port from which the FTP client is connected. (Inherited from Xceed.Ftp.FtpClient) |
![]() | LocalDataAddress | Gets or sets the IP address and port of the client-side data connection to use in subsequent data connections. If FtpClient.PassiveTransfer is false, this property represents the address of the client-side listening socket waiting for the server’s data connection request. (Inherited from Xceed.Ftp.FtpClient) |
![]() | PassiveTransfer | Gets or sets a boolean value indicating if the FTP client should initiate the data connection rather than the FTP server. (Inherited from Xceed.Ftp.FtpClient) |
![]() | PreAllocateStorage | Gets or sets a boolean value indicating if the FTP server must reserve enough space before a file is sent. (Inherited from Xceed.Ftp.FtpClient) |
![]() | Proxy | Gets or sets the proxy client to use for connecting and/or logging in via a proxy server. (Inherited from Xceed.Ftp.FtpClient) |
![]() | RepresentationType | Gets or sets a value indicating how the data is transferred to and from the FTP server. (Inherited from Xceed.Ftp.FtpClient) |
![]() | SendTelnetInterruptSignal | Gets or sets a value indicating if the Telnet interrupt signal should be sent before the QUIT command is sent to an FTP server, allowing an FTP server to be notified that the connection will be terminated. This property does not apply to the Compact Framework. (Inherited from Xceed.Ftp.FtpClient) |
![]() | SendTypeCommand | Gets or sets a boolean value indicating if the TYPE command should be sent before initiating a file transfer. (Inherited from Xceed.Ftp.FtpClient) |
![]() | ServerAddress | Gets the IP address and port to which the FTP client is connected. (Inherited from Xceed.Ftp.FtpClient) |
![]() | ServerFolderSeparator | Gets or sets the FTP server's folder separator character. (Inherited from Xceed.Ftp.FtpClient) |
![]() | State | Gets a value indicating the current state of the FTP client. (Inherited from Xceed.Ftp.FtpClient) |
![]() | SynchronizingObject | Gets or sets the object used to automatically redirect events on the main UI thread. (Inherited from Xceed.Ftp.FtpClient) |
![]() | Timeout | Gets or sets a value, in seconds, indicating after what period of time an FTP operation should timeout. (Inherited from Xceed.Ftp.FtpClient) |
![]() | TraceWriter | Gets or sets the System.IO.TextWriter which will trace the connection/deconnection process as well as the commands and replies sent to and received from the FTP server. (Inherited from Xceed.Ftp.FtpClient) |
![]() | TraceWriterTimestampFormat | (Inherited from Xceed.Ftp.FtpClient) |
![]() | TraceWriterTimestampFormatProvider | (Inherited from Xceed.Ftp.FtpClient) |
![]() | TraceWriterTimestampUTC | (Inherited from Xceed.Ftp.FtpClient) |
![]() | TransferMode | Gets the transfer mode used to send and receive data to and from an FTP server. (Inherited from Xceed.Ftp.FtpClient) |
![]() | UseRemoteAddress | Gets or sets a value indicating whether to use the remote address. (Inherited from Xceed.Ftp.FtpClient) |
Name | Description | |
---|---|---|
![]() | Abort | Aborts the current FTP command. (Inherited from Xceed.Ftp.FtpClient) |
![]() | Authenticate | Overloaded. Authenticates and encrypts the current FTP connection. (Inherited from Xceed.Ftp.FtpClient) |
![]() | BeginAbort | Begins the process of aborting the current FTP command. Don't forget to call EndAbort! |
![]() | BeginAuthenticate | Overloaded. Begins the authentification and encryption of the current FTP connection. Don't forget to call EndAuthenticate! |
![]() | BeginChangeCurrentFolder | Begins the process of changing the current working folder of the FTP server. Don't forget to call EndChangeCurrentFolder! |
![]() | BeginChangeDataChannelProtection | Begins the process of changing the data channel protection. Don't forget to call EndChangeDataChannelProtection! |
![]() | BeginChangeListingMethod | |
![]() | BeginChangeToParentFolder | Begins the process of changing the current working folder of the FTP server to the parent folder. Don't forget to call EndChangeToParentFolder! |
![]() | BeginChangeTransferMode | Begins the process of changing the transfer mode. Don't forget to call EndChangeTransferMode! |
![]() | BeginChangeUser | Overloaded. Begins the process of changing the currently logged-in user to the anonymous user without disconnecting from the FTP server. Don't forget to call EndChangeUser! |
![]() | BeginClearCommandChannel | Begins the process of clearing the command channel. Don't forget to call EndClearCommandChannel! |
![]() | BeginConnect | Overloaded. Begins the connection process of the FTP client to an FTP server on port 21. Don't forget to call EndConnect! |
![]() | BeginCreateFolder | Begins the process of creating a folder on the FTP server. Don't forget to call EndCreateFolder! |
![]() | BeginDeleteFile | Begins the process of deleting a file from the FTP server. Don't forget to call EndDeleteFile! |
![]() | BeginDeleteFolder | Overloaded. Begins the processing of deleting a folder from the FTP server. Don't forget to call EndDeleteFolder! |
![]() | BeginDisconnect | Begins the process of disconnecting the FTP client from the FTP server to which it is connected. Don't forget to call EndDisconnect! |
![]() ![]() | BeginFxpCopy | Overloaded. |
![]() | BeginGetCurrentFolder | Begins the process of retrieving the current working folder of the FTP server. Don't forget to call EndGetCurrentFolder! |
![]() | BeginGetDownloadStream | Overloaded. Begins the process of retrieving a direct access to the readonly data stream being received. Don't forget to call EndGetDownloadStream! |
![]() | BeginGetFolderContents | Overloaded. Begins the process of retrieving the contents of the current working folder. Don't forget to call EndGetFolderContents! |
![]() | BeginGetRawExtendedFeatures | Begins the process retrieving a list of the extended features that are implemented by the FTP server. Don't forget to call EndGetRawExtendedFeatures! |
![]() | BeginGetRawFolderContents | Overloaded. Begins the process of retrieving an unprocessed, clear text list representing the contents of the current working folder as sent by the FTP server and indicates if the entire listing or only filenames should be retrieved. Don't forget to call EndGetRawFolderContents! |
![]() | BeginGetUploadStream | Overloaded. Begins the process of retrieving a direct access to the write-only data stream to send to. |
![]() | BeginLogin | Overloaded. Begins the anonymous login process of the FTP client to the FTP server to which it is connected. Don't forget to call EndLogin! |
![]() | BeginReceiveFile | Overloaded. Begins the process of receiving the specified file from the current working folder and stores it on the local system using the specified path and filename. Don't forget to call EndReceiveFile! |
![]() | BeginReceiveMultipleFiles | Begins the process of retreiving the files that match the provided file mask from the current working folder and stores them on the local system in the specified folder. Don't forget to call EndReceiveMultipleFiles! |
![]() | BeginRenameFile | Begins the process of renaming a file on the FTP server. Don't forget to call EndRenameFile! |
![]() | BeginSendCustomCommand | Begins the process of sending a custom command to the FTP server. Don't forget to call EndSendCustomCommand! |
![]() | BeginSendFile | Overloaded. Begins the process of sending the specified file to the FTP server's current working folder and stores it using the same filename. Don't forget to call EndSendFile! |
![]() | BeginSendFileToUniqueName | Overloaded. Begins the process of sending the specified file to the FTP server's current working folder and stores it using a unique filename. Don't forget to call EndSendFileToUniqueName! |
![]() | BeginSendMultipleFiles | Begins the process of sending the files that match the provided file mask to the FTP server's current working folder. Don't forget to call EndSendMultipleFiles! |
![]() | ChangeCurrentFolder | Changes the current working folder of the FTP server. (Inherited from Xceed.Ftp.FtpClient) |
![]() | ChangeDataChannelProtection | Changes the data channel protection. (Inherited from Xceed.Ftp.FtpClient) |
![]() | ChangeListingMethod | Changes the current listing method that is used to retrieve folder contents from the FTP server. (Inherited from Xceed.Ftp.FtpClient) |
![]() | ChangeToParentFolder | Changes the current working folder of the FTP server to the parent folder. (Inherited from Xceed.Ftp.FtpClient) |
![]() | ChangeTransferMode | Changes the current transfer mode. (Inherited from Xceed.Ftp.FtpClient) |
![]() | ChangeUser | Overloaded. Changes the currently logged-in user to the anonymous user without disconnecting from the FTP server. (Inherited from Xceed.Ftp.FtpClient) |
![]() | ClearCommandChannel | Clears the command channel after login to facilitate firewall NAT when connecting using a secure data channel. (Inherited from Xceed.Ftp.FtpClient) |
![]() | Connect | Overloaded. Connects the FTP client to an FTP server on port 21. (Inherited from Xceed.Ftp.FtpClient) |
![]() | CreateFolder | Create a folder on the FTP server. (Inherited from Xceed.Ftp.FtpClient) |
![]() | DeleteFile | Deletes a file from the FTP server. (Inherited from Xceed.Ftp.FtpClient) |
![]() | DeleteFolder | Overloaded. Deletes a folder from the FTP server. (Inherited from Xceed.Ftp.FtpClient) |
![]() | Disconnect | Disconnects the FTP client from the FTP server to which it is connected. (Inherited from Xceed.Ftp.FtpClient) |
![]() | EndAbort | Ends the process of aborting the current FTP command |
![]() | EndAuthenticate | Ends the authentification and encryption of the current FTP connection. |
![]() | EndChangeCurrentFolder | Ends the process of changing the current working folder of the FTP server. |
![]() | EndChangeDataChannelProtection | Ends the change of the data channel protection.. |
![]() | EndChangeListingMethod | |
![]() | EndChangeToParentFolder | Ends the process of changing the current working folder of the FTP server to the parent folder. |
![]() | EndChangeTransferMode | Ends the process of changing the transfer mode. |
![]() | EndChangeUser | Ends the process of changing the currently logged-in user. |
![]() | EndClearCommandChannel | Ends the clearing of the command channel. |
![]() | EndConnect | Ends the connection process of the FTP client to an FTP server. |
![]() | EndCreateFolder | Ends the process of creating a folder on the FTP server. |
![]() | EndDeleteFile | Ends the process of deleting a file from the FTP server. |
![]() | EndDeleteFolder | Ends the process of deleting a folder from the FTP server. |
![]() | EndDisconnect | Ends the process of disconnecting the FTP client from the FTP server to which it is connected. |
![]() ![]() | EndFxpCopy | |
![]() | EndGetCurrentFolder | Ends the process of retrieving the current working folder of the FTP server. |
![]() | EndGetDownloadStream | Ends the process of retrieving a direct access to the readonly data stream being received. |
![]() | EndGetFolderContents | Ends the process of retrieving the contents of the current working folder. |
![]() | EndGetRawExtendedFeatures | Ends the process of retrieving an unprocessed, clear text list of the extended features that are implemented by an FTP server. |
![]() | EndGetRawFolderContents | Ends the process of retrieving an unprocessed, clear text list representing the contents of the current working folder |
![]() | EndGetUploadStream | Ends the process of retrieving a direct access to the write-only data stream to send to. |
![]() | EndLogin | Ends the login process of the FTP client to the FTP server to which it is connected. |
![]() | EndReceiveFile | Ends the process of receiving a file from the FTP server. |
![]() | EndReceiveMultipleFiles | Ends the process of retreiving the files that match the provided file mask from the current working folder and stores them on the local system in the specified folder. |
![]() | EndRenameFile | Ends the process of renaming a file on the FTP server. |
![]() | EndSendCustomCommand | Ends the process of sending a custom command to the FTP server. |
![]() | EndSendFile | Ends the process of sending a file to the FTP server. |
![]() | EndSendFileToUniqueName | Ends the process of sending a file to the FTP server's current working folder and storing it using a unique filename. |
![]() | EndSendMultipleFiles | Ends the process of sending the files that match the provided file mask to the FTP server's current working folder. |
![]() | GetCurrentFolder | Retrieves the current working folder of the FTP server. (Inherited from Xceed.Ftp.FtpClient) |
![]() | GetDownloadStream | Overloaded. Retrieves a direct access to the readonly data stream being received. (Inherited from Xceed.Ftp.FtpClient) |
![]() | GetFolderContents | Overloaded. Retrieves the contents of the current working folder. (Inherited from Xceed.Ftp.FtpClient) |
![]() | GetRawExtendedFeatures | Retrieves an unprocessed, clear text list of the extended features that are implemented by an FTP server. (Inherited from Xceed.Ftp.FtpClient) |
![]() | GetRawFolderContents | Overloaded. Retrieves an unprocessed, clear text list representing the contents of the current working folder as sent by the FTP server and indicates if the entire listing or only filenames should be retrieved. (Inherited from Xceed.Ftp.FtpClient) |
![]() | GetUploadStream | Overloaded. Retrieves a direct access to the write-only data stream to send to. (Inherited from Xceed.Ftp.FtpClient) |
![]() | Login | Overloaded. Login the FTP client anonymously to the FTP server to which it is connected. (Inherited from Xceed.Ftp.FtpClient) |
![]() | ReceiveFile | Overloaded. Receives the specified file from the current working folder and stores it on the local system using the specified path and filename. (Inherited from Xceed.Ftp.FtpClient) |
![]() | ReceiveMultipleFiles | Receives the files that match the provided file mask from the current working folder and stores them on the local system in the specified folder. (Inherited from Xceed.Ftp.FtpClient) |
![]() | RenameFile | Renames a file or, if supported, a folder on the FTP server. (Inherited from Xceed.Ftp.FtpClient) |
![]() | SendCustomCommand | Sends a custom command to the FTP server. (Inherited from Xceed.Ftp.FtpClient) |
![]() | SendFile | Overloaded. Sends the specified file to the FTP server's current working folder and stores it using the same filename. (Inherited from Xceed.Ftp.FtpClient) |
![]() | SendFileToUniqueName | Overloaded. Sends the specified file to the FTP server's current working folder and stores it using a unique filename. (Inherited from Xceed.Ftp.FtpClient) |
![]() | SendMultipleFiles | Sends the files that match the provided file mask to the FTP server's current working folder. (Inherited from Xceed.Ftp.FtpClient) |
Name | Description | |
---|---|---|
![]() | CertificateReceived | Raised when an FTP server's certificate was received and verified. (Inherited from Xceed.Ftp.FtpClient) |
![]() | CertificateRequired | Raised when a client certificate is required by the FTP server, or the one provided (if e.Certificate is not NULL) was rejected. Note: This event is not available in Xceed FTP for .NET Compact Framework because this product does not support Secure FTP. (Inherited from Xceed.Ftp.FtpClient) |
![]() | CommandSent | Raised once for every command sent to the FTP server. (Inherited from Xceed.Ftp.FtpClient) |
![]() | Disconnected | Raised when the FtpClient.Disconnect method is called as well as when the connection is terminated by the FTP server. (Inherited from Xceed.Ftp.FtpClient) |
![]() | FileTransferStatus | Raised for every 4Kb sent or received during a file transfer. (Inherited from Xceed.Ftp.FtpClient) |
![]() | MultipleFileTransferError | Raised when an error occurs while transferring multiple files to or from the FTP server to determine what action should be taken. (Inherited from Xceed.Ftp.FtpClient) |
![]() | ParsingListingLine | Raised when a listing line is received from the FTP server. (Inherited from Xceed.Ftp.FtpClient) |
![]() | ReceivingFile | Raised for each file being received from the FTP server. (Inherited from Xceed.Ftp.FtpClient) |
![]() | ReplyReceived | Raised once for each reply received from the FTP server. If a reply contains multiple lines, they will be received as a group. (Inherited from Xceed.Ftp.FtpClient) |
![]() | SendingFile | Raised for each file being sent to the FTP server. (Inherited from Xceed.Ftp.FtpClient) |
![]() | StateChanged | Raised when the FtpClient.State of the FTP client changes. (Inherited from Xceed.Ftp.FtpClient) |
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2