public byte[] RequestOpen(string path, Flags flags, bool nullOnError = false)
{
byte[] handle = null;
SshException exception = null;
using (var wait = new AutoResetEvent(false))
{
var request = new SftpOpenRequest(ProtocolVersion, NextRequestId, path, Encoding, flags,
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;
}