Renci.SshNet.Sftp.SftpSession.RequestRead C# (CSharp) Method

RequestRead() public method

Performs SSH_FXP_READ request.
public RequestRead ( byte handle, ulong offset, uint length ) : byte[]
handle byte The handle.
offset ulong The offset.
length uint The length.
return byte[]
        public byte[] RequestRead(byte[] handle, ulong offset, uint length)
        {
            SshException exception = null;

            byte[] data = null;

            using (var wait = new AutoResetEvent(false))
            {
                var request = new SftpReadRequest(ProtocolVersion, NextRequestId, handle, offset, length,
                    response =>
                        {
                            data = response.Data;
                            wait.Set();
                        },
                    response =>
                        {
                            if (response.StatusCode != StatusCodes.Eof)
                            {
                                exception = GetSftpException(response);
                            }
                            data = Array<byte>.Empty;
                            wait.Set();
                        });

                SendRequest(request);

                WaitOnHandle(wait, OperationTimeout);
            }

            if (exception != null)
            {
                throw exception;
            }

            return data;
        }