Skip to content

SftpClient.Create thows SshException instead of SftpPathNotFoundException when directories don't exist #566

Closed

Description

@andriysavin

SftpClient.Create documentation states it throws SftpPathNotFoundException if

The specified path is invalid, or its directory was not found on the remote host.

However, when I try to create a file at an non-existing path I get SshException with "Folder not found" message with stack trace starting at SftpSession.RequestOpen. Not only this is confusing and doesn't match documented behavior, but also SshException is too generic to handle this particular case (e.g. create the directory and try again).

Below is the content of the response object:
image

Activity

  1. Rob-Hague commented on Oct 19, 2026

    @Rob-Hague
    Collaborator

    2025.1.0 / #1716 improved this to the extent the protocol allows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions