First, make sure you use the same full/absolute path in your code as you see in the GUI.
If this do0es not help, please attach a full session log file showing the problem (using the latest version of WinSCP) as well as a GUI session log file showing a successful upload.
To generate the session log file, set
Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.