Home Forums .NET libraries Xceed SFTP/FTP for .NET Converting an AbstractFile to an IO.Stream

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

    Can somebody please tell me how to get a remote file with Xceed sFtp as a System.IO.Stream instead of  an FileSystem.AbstractFile? Or, It is a way to convert an FileSystem.AbstractFile to an IO.Stream?

     

    Thanks

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

    Diane [Xceed]
    Moderator
    Post count: 1353

    Hi Ali,

    Please refer to the following example:

       static void StreamExample()
       {
          using( SSHClient ssh = new SSHClient() )
          {
             ssh.Connect( “host” );
             ssh.Authenticate( “USERNAME”, “PASSWORD” );

             using( SFtpSession sftp = new SFtpSession( ssh ) )
             {
                AbstractFile remoteFile = new SFtpFile( sftp, “MyFile.dat” );

                using( Stream stream = remoteFile.OpenRead() )
                {
                   /* You now have a System.IO.Stream from the remote file.
                    * You can read the remote file’s data. */
                }
             }
          }
       }

    If you want a System.IO.Stream to upload data to a remote SFtp file, we suggest you take a look at the technique used in an example in our documentation. It uses a Stream to upload while maintaining good performance:

    http://doc.xceedsoft.com/products/XceedFileSystem/#topic271.html

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

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.