📜  c# winscp 上传文件 - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:39.681000             🧑  作者: Mango

代码示例1
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();
                }