public SFTPHelper(SshConnectionInfo connectionInfo, FileTransferEvent onStart, FileTransferEvent onProgress, FileTransferEvent onEnd) : this(connectionInfo) { m_sshCp.OnTransferStart += onStart; m_sshCp.OnTransferProgress += onProgress; m_sshCp.OnTransferEnd += onEnd; }
private void ConnectServer() { SshConnectionInfo info = new SshConnectionInfo { User = "******", Pass = null, Host = "up.bakery.moe", IdentityFile = PrivateKeyPath, }; helper = new SFTPHelper(info, OnStart, OnProgress, null); helper.Connect(); ChannelSftp c = helper.Sftp.SftpChannel; c.cd("www/creator/windows"); byte[] b = EncodeInfoFile(); foreach (var file in _list) { helper.Upload(new MemoryStream(file.Value), file.Key); helper.Sftp.Cancel(); } helper.Upload(new MemoryStream(b), INFO_FILE); helper.Close(); helper = null; Invoke(new MethodInvoker(() => { textBox2.Text += "上传完成。" + Environment.NewLine; WriteVersionFile(); Clear(); button1.Enabled = true; })); }
public SFTPHelper(SshConnectionInfo connectionInfo) { m_sshCp = new Sftp(connectionInfo.Host, connectionInfo.User); if (connectionInfo.Pass != null) { m_sshCp.Password = connectionInfo.Pass; } if (connectionInfo.IdentityFile != null) { m_sshCp.AddIdentityFile(connectionInfo.IdentityFile, connectionInfo.IdentityFilePassword); } }