SSH.NET icon indicating copy to clipboard operation
SSH.NET copied to clipboard

Text mode upload

Open imapangolin opened this issue 6 years ago • 4 comments

I need to do a text mode upload - one record and a time with the server providing proper carriage control for the platform.

UploadFile does a binary upload. I need to do a text mode transfer. Do you have an example?

imapangolin avatar Jun 11 '20 15:06 imapangolin

@imapangolin I'm in a similar position, I want to download a file with proper carriage control (from OS/400 using EBCDIC). Did you ever figure out how to get SFTPClient or ConnectionInfo to use "text/ASCII mode" transfer?

barrettotte avatar Jun 26 '20 14:06 barrettotte

got textmode instead of using DownloadFile or UploadFile methods with SFTP in SSH you need to use the Text methods in the session object. It is the same behaviour with other SSH SFTP libraries

 PS C:\Users\admin\Documents\Posh-SSH> $sftp.Session | gm -Name *text*


   TypeName: Renci.SshNet.SftpClient

Name          MemberType Definition
----          ---------- ----------
AppendAllText Method     void AppendAllText(string path, string contents), void AppendAllText(string path, string co...
AppendText    Method     System.IO.StreamWriter AppendText(string path), System.IO.StreamWriter AppendText(string pa...
CreateText    Method     System.IO.StreamWriter CreateText(string path), System.IO.StreamWriter CreateText(string pa...
OpenText      Method     System.IO.StreamReader OpenText(string path)
ReadAllText   Method     string ReadAllText(string path), string ReadAllText(string path, System.Text.Encoding encod...
WriteAllText  Method     void WriteAllText(string path, string contents), void WriteAllText(string path, string cont...

here is an example with chilkat where they also address this the same way https://cknotes.com/binary-vs-text-transfers-sftp-ftp/

darkoperator avatar Jun 26 '20 15:06 darkoperator

@darkoperator Perfect, thanks for the quick response! I was not at all aware what those methods were for, makes a lot of sense now

barrettotte avatar Jun 26 '20 15:06 barrettotte

@darkoperator thanks for the help!

drieseng avatar Jun 27 '20 07:06 drieseng