How can I change the directory in SFTP?
The SFTP protocol (Secure File Transfer over SSH) is a protocol that has no relation to FTP -- other than the fact that both do file transfer (but so does HTTP, and nobody would confuse HTTP with FTP, nor would anyone ask how to change the directory in HTTP).
The confusion often arises because applications such as FileZilla will offer a UI that is the same for both SSH/SFTP and for FTP. When you "change the remote directory" in Filezilla w/ an SFTP server, FileZilla is not sending a "change directory" command to the SSH/SFTP server -- because none exists in that protocol and there is not "current working directory" for your session. In SFTP, your "current directory" is always the HOME directory of your SSH user account.
Let's say you "change the directory" in FileZilla to subdirA. What FileZilla does is to note that you are now logically "in subDirA", it will retrieve the directory listing for subdirA and display it for you. If you choose to download a file, such as "zebra.txt", what FileZilla really does is, noting that you are logically in subDirA and that the files you are currently viewing are from subDirA, it will send a request to download "subdirA/zebra.txt". Internally, FileZilla is concatenating what you see as your "current directory" with the filename you are choosing to upload or download.
You, as the application developer, are working with the SFTP protocol. Given that there is no state, meaning you are never "in a current directory", the filepaths you provide must be either relative from the HOME directory of the SSH user account, or an absolute filepath (meaning absolute from the root of the remote filesystem).
As far as I know, the SFTP protocol doesn't have any notion of a "current directory". You always need full paths.