Renci.SshNet.Common.PipeStream.Flush C# (CSharp) Méthode

Flush() public méthode

When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.
Once flushed, any subsequent read operations no longer block until requested bytes are available. Any write operation reactivates blocking reads.
An I/O error occurs. Methods were called after the stream was closed.
public Flush ( ) : void
Résultat void
        public override void Flush()
        {
            if (_isDisposed)
                throw CreateObjectDisposedException();

            _isFlushed = true;
            lock (_buffer)
            {
                // unblock read hereby allowing buffer to be partially filled
                Monitor.Pulse(_buffer);
            }
        }

Usage Example

Exemple #1
0
        /// <summary>
        /// Downloads the specified directory from the remote host to local directory.
        /// </summary>
        /// <param name="directoryName">Remote host directory name.</param>
        /// <param name="directoryInfo">Local directory information.</param>
        /// <exception cref="ArgumentNullException"><paramref name="directoryInfo"/> or <paramref name="directoryName"/> is null.</exception>
        public void Download(string directoryName, DirectoryInfo directoryInfo)
        {
            if (directoryInfo == null)
                throw new ArgumentNullException("directoryInfo");

            if (string.IsNullOrEmpty(directoryName))
                throw new ArgumentException("directoryName");

            using (var input = new PipeStream())
            using (var channel = this.Session.CreateChannel<ChannelSession>())
            {
                channel.DataReceived += delegate(object sender, Common.ChannelDataEventArgs e)
                {
                    input.Write(e.Data, 0, e.Data.Length);
                    input.Flush();
                };

                channel.Open();

                //  Send channel command request
                channel.SendExecRequest(string.Format("scp -prf \"{0}\"", directoryName));
                this.SendConfirmation(channel); //  Send reply

                this.InternalDownload(channel, input, directoryInfo);

                channel.Close();
            }
        }
All Usage Examples Of Renci.SshNet.Common.PipeStream::Flush