Exemple #1
0
 internal bool Get(string tempstr, string localpath)
 {
     try
     {
         sshCp.Get(tempstr, localpath);
         return(true);
     }catch
     {
         return(false);
     }
 }
Exemple #2
0
        private void send_Click_1(object sender, EventArgs e)
        {
            Host         = this.IP.Text;
            User         = this.userName.Text;
            Pass         = this.password.Text;
            IdentityFile = this.targetPath.Text;

            if (!type && !checkDir(IdentityFile))
            {
                MessageBox.Show("路径格式错误");
                return;
            }

            Util.SshConnectionInfo input = Util.GetConnectionInfo(Host, User, Pass, IdentityFile);

            sshCp          = new Scp(input.Host, input.User);
            sshCp.Password = input.Pass;
            try
            {
                sshCp.Connect();
                MessageBox.Show("连接主机成功");
            }
            catch
            {
                MessageBox.Show("连接主机失败");
                return;
            }
            try
            {
                if (type)
                {
                    sshCp.Get(this.targetPath.Text, this.sourcePath.Text);
                    //  sshCp.Put(this.sourcePath.Text, handleDir(this.sourcePath.Text, this.targetPath.Text));
                    MessageBox.Show("下载成功");
                }
                else
                {
                    sshCp.Put(this.sourcePath.Text, handleDir(this.sourcePath.Text, this.targetPath.Text));
                    MessageBox.Show("上传成功");
                }
            }
            catch
            {
                MessageBox.Show("文件传送失败");
            }
        }
Exemple #3
0
        public bool Download(string remotePath, string localPath)
        {
            try
            {
                if (!m_sshCp.Connected)
                {
                    m_sshCp.Connect();
                }

                m_sshCp.Get(remotePath, localPath);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemple #4
0
 public void CopyFileFromRemote(string localPath, string remotePath)
 {
     _sshCp.Connect();
     _sshCp.Get(remotePath, localPath);
     _sshCp.Close();
 }