Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi IDFtp + Download +Dir (https://www.delphipraxis.net/11601-idftp-download-dir.html)

horst 10. Nov 2003 13:34


IDFtp + Download +Dir
 
habe versucht mit:
Code:
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
  stl : tstringlist;
begin
idftp1.Connect;
if idftp1.connected then
 begin
  stl:=tstringlist.Create;
 IdFTP1.List(DirectoryListBox.Items,'*.*', False);
  try
    for i := 0 to DirectoryListBox.items.count - 1 do
    begin
      stl.Add(DirectoryListBox.items.strings[DirectoryListBox.itemindex]);
      DirectoryListBox.ItemIndex:=DirectoryListBox.ItemIndex+1;
    end;
    idftp1.Get( stl,'c:\Test\'+ stl);
  finally
    stl.Free;
  end;
  idftp1.Disconnect
 end;
end;
ein komplettes ftp-verzeichnis downzuloaden...was nicht funktioniert.
mag mir jemand zeigen was ich falsch mache?

rebugger 10. Nov 2003 13:50

Re: IDFtp + Download +Dir
 
idftp1.Get( stl,'c:\Test\'+ stl); <= Nimmt .Get() denn ne StringList an ?

horst 10. Nov 2003 13:52

Re: IDFtp + Download +Dir
 
sorry hätte auch die fehlermeldung mitschicken sollen.
Zitat:

inkompatible typen string und tstringlist
wie ändere ich das?

grüsse ;)

scp 10. Nov 2003 14:16

Re: IDFtp + Download +Dir
 
Eine StringList kann bei get nicht verwendet werden. Probiers mal so z.B.:

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
  i:integer;
  stl : tstringlist;
begin
idftp1.Connect;
if idftp1.connected then
 begin
  stl := tstringlist.Create;
  try
    IdFTP1.List(stl, '*.*', False);
    DirectoryListBox.Items.AddStrings(stl);

    for i := 0 to stl.count - 1 do
    begin
      try
        idftp1.Get(stl[i], 'c:\Test\' + stl[i]);
      except
        on E: EIdException do // Hierfür musst du die unit IdException in uses eintragen.
          ShowMessage('FTP-Fehler' + #10 + E.Message); // Nur ein Beispiel, kannst die Fehler auch in ne Listbox oder in ein Label oder so übergeben.
        else
          raise;
      end;
    end;
  finally
    stl.Free;
  end;
  idftp1.Disconnect;
 end;
end;

horst 10. Nov 2003 14:22

Re: IDFtp + Download +Dir
 
perfekt...
nun sehe ich meine fehler...danke :balloon:

horst 10. Nov 2003 14:25

Re: IDFtp + Download +Dir
 
wenn diese dateien schon auf der platte sind gibts ne execption "dateien schon vorhanden"
wie kann ich das lösen?

sharkx 10. Nov 2003 14:31

Re: IDFtp + Download +Dir
 
If FileExists() -> skip ;P

horst 10. Nov 2003 14:35

Re: IDFtp + Download +Dir
 
ich bin nicht sicher wie ich das machen soll...
Delphi-Quellcode:
try
        idftp1.Get(stl[i], 'c:\Test\' + stl[i]);
         If FileExists(stl[i]) Then
       exit;
      except
      on E: EIdException do // Hierfür musst du die unit IdException in uses eintragen.
          ShowMessage('FTP-Fehler');
       else
funktioniert nicht...

scp 10. Nov 2003 14:54

Re: IDFtp + Download +Dir
 
FileExists musst du über das Get setzen und statt Exit; musst du Continue; verwenden, damit die Dateien, die danach kommen, noch geladen werden.

Exit --> verlässt die prozedur (in dem Fall Button1Click)
Continue --> geht zur nächsten Zahl in der for-Schleife

horst 10. Nov 2003 16:23

Re: IDFtp + Download +Dir
 
ich krieg das nicht eingefügt...finde auch nirgends ein passendes beispiel..
hilfe ;)


Alle Zeitangaben in WEZ +1. Es ist jetzt 19:53 Uhr.
Seite 1 von 2  1 2      

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz