0 votes
by (120 points)

I naively thought that to get a Unix based LF into a ASCII based CRLF all I would have to do is set the transfer mode to ASCII. However, just setting the transfer mode is not transforming Hex 0A with Hex 0A0D. Is there any way to transform a UNIX LF in a Windows CRLF?

Applies to: Rebex SFTP

1 Answer

0 votes
by (144k points)

The ASCII transfer mode in Rebex SFTP is little bit more complex than in FTP. In FTP, the transformation is done by the server. In SFTP, it is done by the client.

The behavior of Rebex SFTP depends on whether it's possible to determine the OS type of the SFTP server. If there is a Unix-like OS, all CRLF (0D0A) sequences are converted to LF (0A) during upload and all LF (0A) sequences are converted to CRLF (0D0A) during download.

If it's not possible to to determine whether there is a Unix-like OS (this is often the case with SFTP v3), no conversion is done. However, you can still force it by manually setting Sftp object's ServerType property to SftpServerType.Unix:

client.ServerType = SftpServerType.Unix

(where "client" is an instance of Sftp)

This needs to be done in addition to setting TransferType to ASCII.