SftpClient.Exists always return true

Nov 17, 2013 at 7:55 PM
Even if a file does not exist SftpClient.Exists will return true. I have double checked that the file does not exist and I have even tried SftpClient.DeleteFile afterwards, which throws a SftpPathNotFoundException.

The remote server is Bitvise SSH server running Windows 7.
Nov 17, 2013 at 8:21 PM
Edited Nov 28, 2013 at 8:04 PM
I have done some debugging and SftpSession.RequestRealPath doesn't return null as SftpClient.Exists expects, but a array of KeyValuePair<string, SftpFileAttributes> with 1 item where SftpFileAttributes are empty/has bogus values (userid=-1, groupid=-1, size=-1 etc)

Edit: anyone with the same problem see issue #1574
Jan 21, 2014 at 4:43 AM
I've just bumped into this issue as well. It only seems to occur when using a remote sshd for me.

The issue tracker appears to be down. Was there a useful workaround in the bug report?
Feb 10, 2014 at 5:50 PM
I've created this little function in my project and I don't have any problems.
public bool Exists(string remotefilepath)
    catch (SftpPathNotFoundException)
        return false;
    return true;
May 7, 2014 at 8:12 PM
The Exists method should work just fine as of changeset 34957:

This fix will be part of the upcoming beta 2 release.
Marked as answer by drieseng on 5/7/2014 at 1:12 PM