Search code examples
delphiindy

Indy download selected file from the listbox


I never used Indy and am struggling to learn the basic. Took me some time to figure out how to populate the listbox. Now that I have done that how can I download the selected file in the listbox ? I tried :

procedure TFTP.Button2Click(Sender: TObject);
var
i:integer;
begin
for i := 0 to ListBox1.Items.Count - 1 do begin
if ListBox1.Selected[i] then begin
IdFTP1.Get(listbox1.Selected[i]);
end;
end;
end;

But I am getting :

[dcc32 Error] FTP_Form.pas(75): E2250 There is no overloaded version of 'Get' that can be called with these arguments

Or do I need to use a savedialog too? Please help me with this. :)


Solution

  • One way ....

    procedure TFTP.Button2Click(Sender: TObject);
    Var
    Name{, Line}: String;
    begin
    Name := IdFTP1.DirectoryListing.Items[ListBox1.ItemIndex].FileName;
    SaveDialog1.FileName := Name;
    if SaveDialog1.Execute then begin
    IdFTP1.Get(Name, SaveDialog1.FileName, true);
    end;
    end;