Home Forums .NET libraries Xceed SFTP/FTP for .NET Can Xceed.Sftp make use of existing Xceed.Ftp code.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • User (Old forums)
    Post count: 23064
    #21525 |

    I’m using Xceed.Ftp and Xceed.Compression libraries in .NET.  In the same application I also need to perform FTP over SSH for SFTP.  Can I use Xceed.Sftp to create the SSH FTP session and leverage my existing Xceed.Ftp code?  Is there a sample for doing this?  Or, do I have to have different workflows for FTP and SFTP? Thanks.

    Applies to Xceed SFTP for .NET. Imported from legacy forums. Posted by john (had 58 views)

    Fawzi [Xceed]
    Post count: 722

    Hi John,

    Ftp and SFtp over SSH are 2 very different protocols. This is why they are 2 different components.

    However, both Ftp and SFtp use the FileSystem API of usage. As such, if your application uses the FtpFile and FtpFolder classes, you can leverage some parts of your existing code or at least the logic by making clever use of abstraction and polymorphism.

    FtpFile and FtpFolder derive from AbstractFile and AbstractFolder respectively. In the SFtp component, SFtpFile and SFtpFolder also derive from AbstractFile and AbstractFolder.

    So you can write code where AbstractFile and AbstractFolder objects are used where sometimes they are actually Ftp, other times SFtp.

    Example (C#):

    public AbstractFolder SetupDestination()
      AbstractFolder destination;

      if( usingSFtpRightNow )
        destination = new SFtpFolder( sftpSession, “SomeFolder” );
        destination = new FtpFolder( ftpConnection, “SomeFolder” );

      return destination;

    public void SomeFunction()
      AbstractFile sourceFile = new DiskFile( “SomeFile.dat” );

      AbstractFolder destinationFolder = SetupDestination();

      sourceFile.CopyTo( destinationFolder, true );

    Applies to Xceed SFTP for .NET. Imported from legacy forums. Posted by Fawzi [Xceed] (had 27 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.