It looks like you are calling FileTransferClient
object's Delete
method to delete the non-existent directory. The Delete
method, along with Upload
, Download
or GetItems
, is a multi-file method that does not directly correspond to a single SFTP protocol request - it can involve multiple files and directories.
As part of its operation, the method first tried to determine whether the specified directory exists. When it determined that it doesn't (by issuing SSH_FXP_LSTAT
request and receiving the response indicating the item does not exist), it failed with an SftpException
with a Status
of OperationFailure
, indicating that the requested operation (deleting the specified directory) could not be completed - but that's not considered a SFTP-protocol-level error. Therefore, the lack of ProtocolCode
in this case is by design.
On the other hand, if you used a single-file methods such as RemoveDirectory
or DeleteFile
to delete a directory or a file, this would result in the SFTP client issuing a single SSH_FXP_RMDIR
or SSH_FXP_REMOVE
request. And if the server rejected that request, an SftpException
with Status
of ProtocolError
would be raised. THose exceptions represent SFTP-protocol-level errors and ProtocolCode
is available for those.