Reputation: 11
I am using the Renci ssh.net library to upload a file from a Windows device to a Linux node. Before uploading the file I looked at in NotePad++ and at the end of each line was only a LF character. But after uploading the file there is a CRLF character at the end of each line. How can I preserve just the LF character when using Renci ssh.net library?
Upvotes: 0
Views: 614
Reputation: 91
I am super late to the conversation, but my issue was very similar to Ron's.
Long story short, I was using
var file = _sftpClient.CreateText($"{remoteFilePath}/{fileName}");
file.WriteLine(fileContent);
file.Close();
Instead of
var file = _sftpClient.CreateText($"{remoteFilePath}/{fileName}");
file.Write(fileContent);
file.Close();
If someone writes to a file one line at a time, it can reproduce the issue that was described in the question.
Upvotes: 0
Reputation: 25946
You need to use binary mode, that will transfer files without these weird conversions. If you want some code, please provide yours.
Upvotes: 0