Post a reply

Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)


Topic review


Re: Terminate the download path with a slash "/" or not?

For Session.ListDirectory, the path should not end with a slash.

For Session.PutFiles, the target path should end with a slash, optionally followed with a target file name or an operation mask.

Terminate the download path with a slash "/" or not?

I used WinSCP to download/upload files from/to a remote server using the SFTP protocol. The client recently switched to Secure FTP as they no longer supports the SFTP protocol. I changed the way I create the Session so I use Protocol.Ftp with all the other settings, such as the FtpMode and the FtpSecure parameters. In SFTP, the remote folder from which I was reading the files had a path that was terminated with a forward slash, something like this "/folder/subfolder/". Once I switched to FTPS, I started getting errors regarding the remote host, something along the lines of "can't get the attributes of file ..." because "file or folder '/folder/subfolder/' does not exist". That was weird. After I played with it for a while, I noticed that in the WinSCP application, once it connects to the remote server, the path is listed without the final forward slash. I changed it in my application as well (so now my remote folder is indicated "/folder/subfolder") and everything works fine.

The interesting thing is that the upload folder is still indicated as "/folder/uploadSubfolder/" and it's still working.

Can anyone confirm that this is the right thing I need to do or is it more to it and I just haven't figured it yet.