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?
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.).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.