Renci.SshNet.ScpClient.InternalDownload C# (CSharp) Method

InternalDownload() private method

private InternalDownload ( IChannel channel, Stream input, Stream output, string filename, long length ) : void
channel IChannel
input Stream
output Stream
filename string
length long
return void
        private void InternalDownload(IChannel channel, Stream input, Stream output, string filename, long length)
        {
            var buffer = new byte[Math.Min(length, BufferSize)];
            var needToRead = length;

            do
            {
                var read = input.Read(buffer, 0, (int) Math.Min(needToRead, BufferSize));

                output.Write(buffer, 0, read);

                RaiseDownloadingEvent(filename, length, length - needToRead);

                needToRead -= read;
            }
            while (needToRead > 0);

            output.Flush();

            //  Raise one more time when file downloaded
            RaiseDownloadingEvent(filename, length, length - needToRead);

            //  Send confirmation byte after last data byte was read
            SendConfirmation(channel);

            CheckReturnCode(input);
        }

Same methods

ScpClient::InternalDownload ( IChannelSession channel, Stream input, FileSystemInfo fileSystemInfo ) : void