Using the SFTP component to connect to an SCP server

To authenticate to an SCP server, you can simply perform the following steps: Connect to the SFTP/SCP server, verify the server's fingerprint, use your user name and password to login, do your work like uploading file, downloading file, etc. After completing your work, call the Disconnect method to close the SCP session. The example below shows how to authenticate to an SCP server.

// Create a new instance.
Scp client = new Scp();
try
{
   // Connect to the SCP server.
   client.Connect("localhost");
   // Authenticate.
   client.Authenticate("test", "test");
   // ...
   // Disconnect.
   client.Disconnect();
}
catch (ScpException exc)
{
   Console.WriteLine("An error occurred: Code: {0}, Message: {1}", exc.Status, exc.Message);
   if (client.State != RemoteFileSystemState.Disconnected)
       client.Disconnect();
}

' Create a new instance.
Dim client As New Scp()
Try
    ' Connect to the SCP server.
    client.Connect("localhost")
    ' Authenticate.
    client.Authenticate("test", "test")
    ' ...
    ' Disconnect.
    client.Disconnect()
Catch exc As ScpException
    Console.WriteLine("An error occurred: Code: {0}, Message: {1}", exc.Status, exc.Message)
    If client.State <> RemoteFileSystemState.Disconnected Then
        client.Disconnect()
    End If
End Try