SFTP WS_FTP OpenFile “Folder not found” Error

If you pass a filename with no path to the SFTP OpenFile method, and the SFTP server is WS_FTP, you may get a “Folder not found” error.

An SFTP server *should* open or create the file in the home directory of the logged-in account. This doesn’t seem to be the case with the WS_FTP server. The fix is to call RealPath(“.”,””) to get the absolute path of the logged-in account, and then combine this with the filename and pass it to OpenFile.

For example, if trying to OpenFile(“helloWorld.txt”)

and RealPath(“.”,””) returns “/chilkat”,

then do this: OpenFile(“/chilkat/helloWorld.txt”)

Tags :