Sending File in ASCII Format

0 votes
asked Jan 7, 2011 by Bruce (120 points)
edited Apr 1, 2011

We are testing the Rebex component. Specifically we are testing the FTP SSL for .NET 2.0 Trial component. The code in C# is as follows

   //Create Rebex FTP Component    
   Ftp rebexFTP = new Ftp();    
   rebexFTP.Connect(strURL,  20021, null, FtpSecurity.Explicit);    
   rebexFTP.Login(strUser strPass);    
   rebexFTP.ChangeDirectory(FTPHomeDirectory);    
   rebexFTP.ChangeDirectory(FTPUploadDirectory);    
   numBytes = rebexFTP.PutFile(strFileName);

The good news is that this code works – we are able to Connect using the port, Login, Change Directories and Upload the file. The only problem is that this file is sent in binary format and needs to be sent in ASCII format. Is there a way to tell the Rebex component to upload the file in ASCII on the PutFile method?

When we test using a FTP client Core FTP we are able to upload the file in ASCII format using the same Login, port directories etc.

Applies to: Rebex FTP/SSL

1 Answer

0 votes
answered Jan 7, 2011 by Martin Vobr (12,950 points)
edited Jan 7, 2011

The Ftp class default transfer mode is binary. To upload file in ASCII format try setting the TransferType property to FtpTransferType.Ascii first.

//Create Rebex FTP Component    
Ftp rebexFTP = new Ftp();    
rebexFTP.Connect(strURL,  20021, null, FtpSecurity.Explicit);    
rebexFTP.Login(strUser strPass);    
rebexFTP.ChangeDirectory(FTPHomeDirectory);    
rebexFTP.ChangeDirectory(FTPUploadDirectory); 

// change transfer mode to ASCII and upload the file
rebexFTP.TransferType = FtpTransferType.Ascii;
numBytes = rebexFTP.PutFile(strFileName);
...