Get() public method

public Get ( string fromFilePath, string toFilePath ) : void
fromFilePath string
toFilePath string
return void
示例#1
2
        public void DownloadFile(ResourceNode node, string remotePath, string localPath)
        {
            if (_sftpClient != null)
            {
                using (var stream = File.OpenWrite(localPath))
                {
                    _sftpClient.DownloadFile(remotePath, stream);
                }

                //scp = _scpPool.GetSshSession(true, node);
                //scp.Recursive = recursive;
                //scp.Download(remotePath, new FileInfo(localPath));
            }
            else
            if (_scp != null)
            {
                _scp.Get(remotePath, localPath);
            }
            else
            {
                throw new Exception("No connection established to node for copy");
            }
        }
示例#2
0
        private void ScpGet(ResourceNode node, string remotePath, string localPath)
        {
            var scp = new Ssh.Scp(node.NodeAddress, node.Credentials.Username, node.Credentials.Password);

            scp.Connect();
            scp.Recursive = true;
            scp.Get(remotePath, localPath);
            scp.Close();
        }
示例#3
0
 public static bool DownloadScp(string server, string remoteFileName, string localFileName, string username, string password)
 {
     try {
     SshTransferProtocolBase sshCp = new Scp(server, username, password);
     sshCp.Connect();
     sshCp.Get(remoteFileName, localFileName);
     sshCp.Close();
     return true;
       } catch (Exception e) {
     nlogger.ErrorException("while downloading this happened", e);
     return false;
       }
 }