SFTP OpenFile Succeeds, but ReadFileBytes Fails
SSH/SFTP servers are notoriously bad at providing any sort of useful information about the cause of a problem. This is one of those cases. It was discovered that for one particular server, if a remote file is opened (via the OpenFile method) using “readWrite” access, then the OpenFile succeeds, but a subsequent call to a method such as ReadFileBytes fails. The only information from the server is an error code “10”. Gee, thanks! What the #@!$%! is an error code “10”??? (Usually an SSH server will also provide a short and utterly useless 1-line error description, but this particular server was too lazy to even do that.)
In the end, after fiddling around with different access and disposition choices, it was found that using “readOnly” for the access and “openExisting” for the create disposition solved the problem.