This question is somewhat beyond the scope of Rebex support because it deals with .NET's MemoryStream
class rather than Rebex SFTP.
Please use general-purpose software development forums such as Stack Overflow for these kinds of questions.
However, this code do the trick:
// download file into memory
var downloaded = new MemoryStream();
client.GetFile("/file.txt", downloaded);
// prepare for reading
downloaded.Position = 0;
// read all as string
string text;
using (var reader = new StreamReader(downloaded))
{
text = reader.ReadToEnd();
}
// replace <CR><LF> to single <LF>
string output = text.Replace("\r\n", "\n");
// or remove any <CR> and any <LF>
output = text.Replace("\r", "").Replace("\n", "");
// write output to file
File.WriteAllText(@"c:\data\output.txt", output);
// or to MemoryStream
var data = new MemoryStream(Encoding.UTF8.GetBytes(output));