Search code examples
delphiftpindy

Indy FTP TransferType


I'm using the IdFTP (Indy 10) component to download some files (zip and txt) from a remote location. Before getting each file I set the TransferType to binary.

IdFTP.TransferType := ftBinary;
IdFTP.Get(ASource, ADest, AOverwrite);

I expect that both text and binary files can be downloaded using the binary mode. However it looks like text files contents is messed up while zip files are downloaded correctly. If I set the TransferType to ASCII for text files it works as expected. How can I detect which TransferType to set for a given file? Is there a common denominator or auto setting?


Solution

  • I don't see how the Binary flag can mess up transferred files. Binary type means the server transfers the files without any processing, as is.

    The only thing that an FTP server should use the ASCII flag for, is to correctly handle the end of line in text files, usually (1) either only Line Feed in Unix or (2)Carriage Return + Line Feed in Windows. But nowadays most text editors handle both in either system.

    So the safest is use only ASCII flag for very well known text files, probably only files with a .txt extension, and use Binary flag for all the others.