📅  最后修改于: 2022-03-11 14:48:39.681000             🧑  作者: Mango
var tofile = new FileInfo(sourceFile).Name;
// Setup session options
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Sftp,
HostName = ftphostname,
UserName = login,
Password = password,
SshHostKeyFingerprint = ftpkey
};
using (Session session = new Session())
{
// Connect
session.Open(sessionOptions);
var ftpFile = uploadDir + "/" + tofile;
session.PutFiles(sourceFile, ftpFile, true).Check();
}