Although Rebex SFTP itself doesn't support EBCDIC to ASCII transformation, .NET's System.Text.Encoding
object does and can be used with Rebex SFTP easily.
To download an EBCDIC file using the Sftp
object and save it as ASCII, use the following code:
var sftp = new Sftp();
sftp.Connect(...);
sftp.Login(...);
// create a memory stream
var ms = new MemoryStream();
// use binary transfer type
sftp.TransferType = SftpTransferType.Binary;
// download an EBCDIC file into the memory stream
sftp.GetFile(remoteFile, ms);
// get an instance of EBCDIC charset (="ibm037")
var ebcdic = System.Text.Encoding.GetEncoding("ibm037");
// convert the EBCDIC contents of the memory stream to a .NET string
string text = ebcdic.GetString(ms.ToArray());
// save the string as ASCII
File.WriteAllText(localFile, text, System.Text.Encoding.ASCII);