public Task<FileSystemTransferStatistics> DeleteDirectoryAsync( string directoryPath, bool recursive, object userState = null )
Remove a directory with contents asynchronously using the DeleteDirectoryAsync method (Task-based approach).
using System; using ComponentPro; using ComponentPro.IO; using ComponentPro.Net; ... static async void Main2() { // Create a new Ftp instance. using (Ftp client = new Ftp()) { // Connect to the FTP server. client.Connect("myserver"); // Authenticate. client.Authenticate("userName", "password"); // ... // The event DeleteDirectoryCompleted is fired when the operation completes. client.DeleteDirectoryCompleted += callback2; // Delete a directory with contents. await client.DeleteDirectoryAsync("/mydir", true, "user state"); // ... } } private static void callback2(object sender, ExtendedAsyncCompletedEventArgs<FileSystemTransferStatistics> e) { if (e.Error != null) Console.WriteLine("Error: " + e.Error.ToString()); Console.WriteLine("Method completed. User state: " + e.UserState); }
Remove a directory with contents asynchronously using the DeleteDirectoryAsync method (Event-based approach).
using System; using ComponentPro; using ComponentPro.IO; using ComponentPro.Net; ... static void Main2() { // Create a new Ftp instance. using (Ftp client = new Ftp()) { // Connect to the FTP server. client.Connect("localhost"); // Authenticate. client.Authenticate("test", "test"); // ... // The event DeleteDirectoryCompleted is fired when the operation completes. client.DeleteDirectoryCompleted += callback2; // Remove a directory with contents. client.DeleteDirectoryAsync("/temp", "user state"); } } static void callback2(object sender, ExtendedAsyncCompletedEventArgs<FileSystemTransferStatistics> e) { // Ftp client = (Ftp)sender; if (e.Error != null) { Console.WriteLine("Error: " + e.Error.ToString()); } Console.WriteLine("User-state: " + e.UserState); }
Remove a directory with contents asynchronously using the DeleteDirectoryAsync method (Task-based approach).
using System; using ComponentPro; using ComponentPro.IO; using ComponentPro.Net; ... static async void Main2() { // Create a new Sftp instance. using (Sftp client = new Sftp()) { // Connect to the SFTP server. client.Connect("myserver"); // Authenticate. client.Authenticate("userName", "password"); // ... // The event DeleteDirectoryCompleted is fired when the operation completes. client.DeleteDirectoryCompleted += callback2; // Delete a directory with contents. await client.DeleteDirectoryAsync("/mydir", true, "user state"); // ... } } private static void callback2(object sender, ExtendedAsyncCompletedEventArgs<FileSystemTransferStatistics> e) { if (e.Error != null) Console.WriteLine("Error: " + e.Error.ToString()); Console.WriteLine("Method completed. User state: " + e.UserState); }
Remove a directory with contents asynchronously using the DeleteDirectoryAsync method (Event-based approach).
using System; using ComponentPro; using ComponentPro.IO; using ComponentPro.Net; ... static void Main2() { // Create a new Sftp instance. using (Sftp client = new Sftp()) { // Connect to the SFTP server. client.Connect("localhost"); // Authenticate. client.Authenticate("test", "test"); // ... // The event DeleteDirectoryCompleted is fired when the operation completes. client.DeleteDirectoryCompleted += callback2; // Remove a directory with contents. client.DeleteDirectoryAsync("/temp", "user state"); } } static void callback2(object sender, ExtendedAsyncCompletedEventArgs<FileSystemTransferStatistics> e) { // Sftp client = (Sftp)sender; if (e.Error != null) { Console.WriteLine("Error: " + e.Error.ToString()); } Console.WriteLine("User-state: " + e.UserState); }