Indy FTP Failing to upload miserably

Using a simple code, such as:

  procedure TForm1.cxButton1Click(Sender: TObject);
  ftp.Host := 'domain';
  ftp.Username := 'user';
  ftp.Password := 'password';

I'm getting the following results:

  • Application freezes while uploading (ergo unable to see Progress Bar position).
  • Uploaded file goes corrupted (corrupts anything more than a few bytes).

What on earth am I doing wrong?

Thank you.


The app freezes because Indy uses blocking operations. While the code is running, the main message loop is not running, so new messages are not being processed until cxButton1Click() exits. To solve that, either place a TIdAntiFreeze component onto your TForm, or else move the TIdFTP code to a separate worker thread, and then use TIdSync or TIdNotify to update the UI safely when needed.

The file will be "corrupted" if you are transferring it in ASCII mode instead of in binary mode. Make sure the TIdFTP.TransferType property is set to ftBinary. Indy 9 and earlier defaulted to ftBinary, but Indy 10 defaults to ftASCII instead (to match the FTP protocol specs).

Need Your Help

Couldn't run my test using Microsoft Test Manager

visual-studio-2012 msbuild mstest microsoft-test-manager mt

When I'm running the test in Microsoft Test Manager I get an error: The build directory of the test run either does not exist or access permission is required.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.