<PackageReference Include="SSH.NET" Version="2020.0.1" />

SftpOpenDirRequest

using Renci.SshNet.Sftp.Responses; using System; using System.Text; namespace Renci.SshNet.Sftp.Requests { internal class SftpOpenDirRequest : SftpRequest { private byte[] _path; private readonly Action<SftpHandleResponse> _handleAction; public override SftpMessageTypes SftpMessageType => SftpMessageTypes.OpenDir; public string Path { get { return Encoding.GetString(_path, 0, _path.Length); } private set { _path = Encoding.GetBytes(value); } } public Encoding Encoding { get; set; } protected override int BufferCapacity => base.BufferCapacity + 4 + _path.Length; public SftpOpenDirRequest(uint protocolVersion, uint requestId, string path, Encoding encoding, Action<SftpHandleResponse> handleAction, Action<SftpStatusResponse> statusAction) : base(protocolVersion, requestId, statusAction) { Encoding = encoding; Path = path; _handleAction = handleAction; } protected override void LoadData() { base.LoadData(); _path = ReadBinary(); } protected override void SaveData() { base.SaveData(); WriteBinaryString(_path); } public override void Complete(SftpResponse response) { SftpHandleResponse sftpHandleResponse = response as SftpHandleResponse; if (sftpHandleResponse != null) _handleAction(sftpHandleResponse); else base.Complete(response); } } }