SCP_ConnectTo() protected method

Connect a channel to the remote server using the 'SCP TO' command ('scp -t')
protected SCP_ConnectTo ( Channel &channel, Stream &server, string rfile, bool recursive ) : void
channel Tamir.SharpSsh.jsch.Channel Will contain the new connected channel
server Stream Will contaun the new connected server I/O stream
rfile string The remote path on the server
recursive bool Idicate a recursive scp transfer
return void
示例#1
0
文件: Scp.cs 项目: swzry/tamir.ssh
        /// <summary>
        /// Opens a <see cref="ScpStream"/> to be used for writing a file to a remote target
        /// </summary>
        /// <param name="host">The name of the remote target</param>
        /// <param name="user">The user to use on the remote target</param>
        /// <param name="password">The user's password</param>
        /// <param name="filePath">The full path, including the filename, on the remote target to write into</param>
        /// <param name="filesize">The size, in bytes, of the file being written</param>
        /// <returns>A <see cref="ScpStream"/> that can be used to write a file</returns>
        public static ScpStream OpenWriteStream(Scp scp, string filePath, long filesize)
        {
            Channel channel = null;
            Stream  server  = null;

            scp.Connect();
            scp.SCP_ConnectTo(out channel, out server, filePath, false);

            // send "C0644 filesize filename", where filename should not include '/'
            string command = "C0644 " + filesize + " " + Path.GetFileName(filePath) + "\n";

            byte[] buff = Util.getBytes(command);
            server.Write(buff, 0, buff.Length); server.Flush();

            return(new ScpStream(channel, server, true));
        }