Autor Beitrag
Robii
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: So 14.06.09 22:19 
Hallo, ich hätte gerne in einem TreeView eine Liste vom Inhalt meines FTP-Servers gehabt. Ich weiß das ich dazu IndyFtp.List benutzen muss, aber leider klappt das bei mir nicht & Google gab auch nichts nützliches. Hoffe ihr könnt mir helfen. Gruß.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
var
  FTP_Inhalt: TStringList;
  MyIdFTP2: TIdFTP;
begin
  FTP_Inhalt:=TStringList.Create;
  try
    MyIdFTP2.UserName:='*****';
    MyIdFTP2.Password:='***';
    MyIdFTP2.Host:='ftp.**.*.funpic.de';
    MyIdFTP2.Connect;
    MyIdFTP2.Create;
    MyIdFTP2.List(Listbox1.Items,'*',true);
      finally
    MyIdFTP2.Free;
  end;
end;


E: Folgenden Code habe ich schon, leider klappt er aber nicht, wegen einer Zugriffsverletzung?


Moderiert von user profile iconNarses: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am So 14.06.2009 um 22:44
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 14.06.09 22:51 
Na gut, ein kleines Beispiel, sollte so klappen glaube ich:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
uses
  IdFTP, IdAllFTPListParsers;

procedure TFormX.ButtonXClick(Sender: TObject);
var
  MyFTP: TIdFTP;
  i: Integer;
  NewItem: TListItem;
begin
  MyFTP := TIdFTP.Create;
  try
    MyFTP.Host := ...
    MyFTP.Username := ...
    MyFTP.Password := ...
    MyFTP.Connect;
    MyFTP.List;
    for i := 0 to MyFTP.DirectoryListing.Count - 1 do
    begin
      NewItem := ListViewX.Items.Add;
      NewItem.Caption := MyFTP.DirectoryListing[i].FileName;
      NewItem.SubItems.Add(MyFTP.DirectoryListing[i].PermissionDisplay);
    end;
  finally
    MyFTP.Free;
  end;
end;
Robii Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: So 14.06.09 23:07 
Wenn ich deinen geposteten Code benutze, passiert bei mir nix. Das heißt mein ListView bleibt einfach leer. Wieso ?
Gruß
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: So 14.06.09 23:32 
Weil der FTP-Server nichts zu bieten (aka keine Dateiliste) hat? Weil die Liste irgendwie leer ist? Verwende doch einfach dein Delphi und Brain 1.0, um in den 3,72 Zeilen den Fehler zu finden...

_________________
Na denn, dann. Bis dann, denn.
Robii Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: Mo 15.06.09 08:07 
Guten Morgen,
das Problem ist das in der ListBox nicht angezeigt wird im Source aber auch kein Fehler angegeben wird. Trotzdem liegen auf dem Ftp-Server Dateien welche er ja vom Prinzip her anzeigen müsste. Verstehe nicht ganz warum die ListBox leer bleibt. Gruß
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 15.06.09 08:26 
Dann versuch eben mal die Auflistung in der StringList FTP_Inhalt. Warum da die Schutzverletzung auftritt, sollte dir ein Vergleich der beiden Quelltexte sagen...
Du erzeugst dein FTP-Objekt nicht... und stattdessen gibst du FTP_Inhalt nicht frei.
Robii Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: Mo 15.06.09 15:09 
Danke klappt jetzt.
Das mit dem Create passiert mir jedes mal schrecklich ist das, sorry.
Gruß