It looks like you are calling
Delete method to delete the non-existent directory. The
Delete method, along with
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
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
DeleteFile to delete a directory or a file, this would result in the SFTP client issuing a single
SSH_FXP_REMOVE request. And if the server rejected that request, an
ProtocolError would be raised. THose exceptions represent SFTP-protocol-level errors and
ProtocolCode is available for those.