public event ExtendedAsyncCompletedEventHandler<TResult> GetItemInfoCompleted
Shows how to use GetItemInfoAsync method to asynchronously retrieve information of a file on an FTP server (Task-based approach).
using System; using ComponentPro.IO; using ComponentPro.Net; using ComponentPro; ... // Create a new class instance. Ftp client = new Ftp(); // Connect to the FTP server. client.Connect("demo.componentpro.com"); // Authenticate. client.Authenticate("test", "test"); // ... // Get information of remote file '/test.dat'. FileInfoBase info = await client.GetItemInfoAsync("/test.dat", true); // ... // Disconnect. client.Disconnect();
Shows how to use GetItemInfoAsync method to asynchronously retrieve information of a file on an FTP server (Event-based approach).
using System; using ComponentPro.IO; using ComponentPro.Net; using ComponentPro; ... static void Main() { // Create a new class instance. Ftp client = new Ftp(); // Connect to the FTP server. client.Connect("demo.componentpro.com"); // Authenticate. client.Authenticate("test", "test"); // ... // Register an event handler. client.GetItemInfoCompleted += client_GetItemInfoCompleted; // Get information of remote file '/test.dat'. client.GetItemInfoAsync("/test.dat", true); // ... // Disconnect. client.Disconnect(); } static void client_GetItemInfoCompleted(object sender, ExtendedAsyncCompletedEventArgs<FileInfoBase> e) { // Ftp client = (Ftp)sender; if (e.Error != null) Console.WriteLine("Error: " + e.Error.Message); else { FtpFileInfo info = (FtpFileInfo)e.Result; Console.WriteLine("Name: {0}, Permissions: {1}", info.Name, info.Permissions); } }
Shows how to use GetItemInfoAsync method to asynchronously retrieve information of a file on an SFTP server (Task-based approach).
using System; using ComponentPro.IO; using ComponentPro.Net; using ComponentPro; ... // Create a new class instance. Sftp client = new Sftp(); // Connect to the SFTP server. client.Connect("demo.componentpro.com"); // Authenticate. client.Authenticate("test", "test"); // ... // Get information of remote file '/test.dat'. FileInfoBase info = await client.GetItemInfoAsync("/test.dat", true); // ... // Disconnect. client.Disconnect();
Shows how to use GetItemInfoAsync method to asynchronously retrieve information of a file on an SFTP server (Event-based approach).
using System; using ComponentPro.IO; using ComponentPro.Net; using ComponentPro; ... static void Main() { // Create a new class instance. Sftp client = new Sftp(); // Connect to the SFTP server. client.Connect("demo.componentpro.com"); // Authenticate. client.Authenticate("test", "test"); // ... // Register an event handler. client.GetItemInfoCompleted += client_GetItemInfoCompleted; // Get information of remote file '/test.dat'. client.GetItemInfoAsync("/test.dat", true); // ... // Disconnect. client.Disconnect(); } static void client_GetItemInfoCompleted(object sender, ExtendedAsyncCompletedEventArgs<FileInfoBase> e) { // Sftp client = (Sftp)sender; if (e.Error != null) Console.WriteLine("Error: " + e.Error.Message); else { SftpFileInfo info = (SftpFileInfo)e.Result; Console.WriteLine("Name: {0}, Permissions: {1}", info.Name, info.Permissions); } }