0

I am trying to download a file from a server in this way:

var MeS:TMemoryStream;
begin
 Mes:=TMemoryStream.Create;
 IdFTP1.Connect;
 Mes.Position:=0;
  try
   IdFTP1.Get(Mes, 'dolcestilnovo.txt', True, False);
  finally
   MeS.Free;
   IdFTP1.Disconnect;
  end;
 Memo5.Lines.LoadFromStream(Mes);
end;

I must show the content of dolcestilnovo.txt inside that Memo5, but I have an error on the IdFTP1.Get(); method.

The error says "There is no overloaded version of 'Get' that can be called with these parameters". What can I do?

I thought to use the MemoryStream since I'm downloading it on an android device.

LU RD
  • 34,438
  • 5
  • 88
  • 296
Alberto Rossi
  • 1,800
  • 4
  • 36
  • 58

1 Answers1

6

Look at the signature of the TStream version of TIdFTP.Get():

procedure Get(const ASourceFile: string; ADest: TStream; AResume: Boolean = false); overload;

See why your code does not match it? Use this instead:

IdFTP1.Get('dolcestilnovo.txt', Mes, False);

And do not forget to reset the TMemoryStream.Position back to 0 again before calling Memo5.Lines.LoadFromStream(Mes) or else it will not load anything.

Try this:

var
  MeS: TMemoryStream;
begin
  Mes := TMemoryStream.Create;
  IdFTP1.Connect;
  try
    IdFTP1.Get('dolcestilnovo.txt', Mes, False);
  finally
    IdFTP1.Disconnect;
  end;
  Mes.Position := 0;
  Memo5.Lines.LoadFromStream(Mes);
end;
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770