更新时间:2023-02-10 22:40:04
你好N0rdin,
Hi N0rdin,
我们可以将内容写入MemoryStream并将Stream上传到Sftp Server。这是一个简单的示例供您参考。
We could write the content to MemoryStream and upload the Stream to Sftp Server. here is a simple sample for your reference.
string host = "host";
int port = 0;//your port
string username = "username";
string password = "pwd";
var client = new SftpClient(host, port, username, password);
client.Connect();
string content = "Test";
byte[] results = Encoding.ASCII.GetBytes(content);
var stream = new MemoryStream();
stream.Write(results, 0, results.Length);
stream.Position = 0;
client.UploadFile(stream, "/remote/path/my.pdf");
致以最诚挚的问候,
张龙