Renci.SshNet.ServiceFactory.CreatePipeStream C# (CSharp) Method

CreatePipeStream() public method

Create a new PipeStream.
public CreatePipeStream ( ) : PipeStream
return PipeStream
        public PipeStream CreatePipeStream()
        {
            return new PipeStream();
        }

Usage Example

Exemplo n.º 1
0
        /// <summary>
        /// Uploads the specified directory to the remote host.
        /// </summary>
        /// <param name="directoryInfo">The directory info.</param>
        /// <param name="path">The path.</param>
        /// <exception cref="ArgumentNullException">fileSystemInfo</exception>
        /// <exception cref="ArgumentException"><paramref name="path"/> is <c>null</c> or empty.</exception>
        public void Upload(DirectoryInfo directoryInfo, string path)
        {
            if (directoryInfo == null)
            {
                throw new ArgumentNullException("directoryInfo");
            }
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentException("path");
            }

            using (var input = ServiceFactory.CreatePipeStream())
                using (var channel = Session.CreateChannelSession())
                {
                    channel.DataReceived += (sender, e) => input.Write(e.Data, 0, e.Data.Length);
                    channel.Open();

                    //  Send channel command request
                    channel.SendExecRequest(string.Format("scp -rt \"{0}\"", path));
                    CheckReturnCode(input);

                    InternalSetTimestamp(channel, input, directoryInfo.LastWriteTimeUtc, directoryInfo.LastAccessTimeUtc);
                    SendData(channel, string.Format("D0755 0 {0}\n", Path.GetFileName(path)));
                    CheckReturnCode(input);

                    InternalUpload(channel, input, directoryInfo);

                    SendData(channel, "E\n");
                    CheckReturnCode(input);
                }
        }
All Usage Examples Of Renci.SshNet.ServiceFactory::CreatePipeStream