SFTP: Can I create a file from a stream using SharpSSH


  • I have been able to successfully copy a file from my local hard drive into an SFTP location using the PUT command.

    However my actual requirement is to create a CSV from some table data, in memory, and copy this to the SFTP location.

    I can't see how to do this with SharpSSH.

    Can someone help me please?

    • Edited by Gordon Johnston Wednesday, April 12, 2017 3:03 PM spelling error
    Wednesday, April 12, 2017 3:02 PM


  • Have used Renci.SshNet instead and that seems to work just fine.

    If there is an answer it might be worth posting for others.

    Anyway, here is a bit of my unrefined, working code.  Hope it is helpful. 

    publicvoid Write(string remoteFile, MemoryStream stream) {     try     {         string host = "";         using (var client = newSftpClient(host, 22, Credentials.Username, Credentials.Password))         {             client.Connect();             Console.WriteLine("Connected to {0}", host);             client.UploadFile(stream, Path.GetFileName(remoteFile));         }



    Wednesday, April 12, 2017 3:54 PM