0

I am creating a memory stream on run time

        var stream = new MemoryStream();
        var writer = new StreamWriter(stream); 
        writer.WriteLine("There could by any text over here....");
        writer.Flush();
        stream.Position = 0;

Now i want to transfer this memory stream via SSH library to a remote SFTP server and want to save it on that SFTP server.

I have tried following code but its not working

     using (var scp = new ScpClient("HostName", "test", "test"))
        {
            scp.Connect();
            scp.Upload(stream, "/Files/Test/temp.txt");
            scp.Disconnect();
        }

it get stuck forever on following line without any error

scp.Upload(stream, "/Files/Test/temp.txt");

Can any one please help?

yrahman
  • 960
  • 5
  • 15
  • 33

1 Answers1

0

Use SftpClient.UploadFile instead of ScpClient.Upload.

If that doesn't help, make sure your firewall is set up properly. It's very helpful to use a tool such as WireShark to monitor the communication in case there's some weird error (it also enables you to easily see authentication errors etc.).

Luaan
  • 62,244
  • 7
  • 97
  • 116