SFTP OpenFile fails with “Folder not found” from SFTP Server

If the SSH/SFTP server responds with a “Folder not found” error in response to calling OpenFile with a remote filepath is just a filename with no path part, then try prepending “./” to the filepath.  For example:

success = sftp.OpenFile(“test.txt”, “writeOnly”, “createTruncate”);

If this fails with a “Folder not found”, then modify your code to this:

success = sftp.OpenFile(“./test.txt”, “writeOnly”, “createTruncate”);

Tags :