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

RequestOpenDir() public method

Performs SSH_FXP_OPENDIR request
public RequestOpenDir ( string path, bool nullOnError = false ) : byte[]
path string The path.
nullOnError bool if set to true returns null instead of throwing an exception.
return byte[]
        public byte[] RequestOpenDir(string path, bool nullOnError = false)
        {
            SshException exception = null;

            byte[] handle = null;

            using (var wait = new AutoResetEvent(false))
            {
                var request = new SftpOpenDirRequest(ProtocolVersion, NextRequestId, path, Encoding,
                    response =>
                        {
                            handle = response.Handle;
                            wait.Set();
                        },
                    response =>
                        {
                            exception = GetSftpException(response);
                            wait.Set();
                        });

                SendRequest(request);

                WaitOnHandle(wait, OperationTimeout);
            }

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

            return handle;
        }