+1 vote
by (160 points)
edited

I am using Rebex to download an EDI File off of a FTP site. It is a standard FTP site, not SFTP or FTPS.

When I download the file, the local file is gibberish, like it is encrypted or something. However if I download the file from the FTP using a client such as FileZilla the file is plain text as it should be.

Text of File should look something like this: ISA*00* 00 *11*XX0XQ933P *ZZ*6750 *110207*0536*U*00400*000000214*0*P*>\

Instead it looks like this: ÉâÁ\ðð\@@@@@@@@@@\ðð\@@@@@@@@@@\ññ\×Óðñøôùóó×@@@@@\éé\öñôð@@@@@@@@@@@\ññðòð÷\ðõóö\ä\ððôðð\ððððððòñô\ð\×\nàÇâ\âÃ\óñøööòñðôð\

Here is sample code:

private static void FtpDownloadFile(string hostName, int port, 
     string username, string password, string initialDirectoryName, 
     string downloadDirectoryPath, string fileName)
    {
        //create download directory if it does not exist
        if (!Directory.Exists(downloadDirectoryPath))
        {
            Directory.CreateDirectory(downloadDirectoryPath);
        }

        if (!string.IsNullOrEmpty(fileName))
        {
            initialDirectoryName += "/" + fileName;
            downloadDirectoryPath += "\\" + fileName;
        }

        //connect to SSH FTP
        Rebex.Net.Ftp client = null;

        client = new Rebex.Net.Ftp();
        client.Connect(hostName, port);
        client.Login(username, password);

        client.GetFile(initialDirectoryName, downloadDirectoryPath);

        //disconnect
        client.Disconnect();
    }
Applies to: Rebex FTP/SSL

1 Answer

0 votes
by (13.3k points)
edited
 
Best answer

Try setting the FTP client transfer mode to ASCII as follows:

    ...

    client.TransferType = FtpTransferType.Ascii;
    client.GetFile(initialDirectoryName, downloadDirectoryPath);

    //disconnect
    client.Disconnect();

If it does not help please create two log files and either include them in your post or mail them to support@rebex.net for analysis:

  1. Rebex FTP log file using a LogWriter property as described here.
  2. FileZilla log file

Differences between the two should help us to determine what went wrong.

by (160 points)
That worked. Thank you.
...