Indy FTP , encore, je découvre .
Je me suis lancé dans une liste des fichiers sur le serveur (dans un ListView)
pas de problème particulier pour une liste sensu-stricto . Par contre , lorsque je suis sur un sous-répertoire ça se corse puisque celui-ci s'affiche même si je n'ai pas l'autorisation d'y accéder par la suite .
D'où ma question , y a t'il un moyen de savoir si le répertoire sera accessible ultérieurement ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69 procedure TForm2.FTPBrowse(dir: string); var L : TStringList; i : integer; repftp : string; root : Boolean; begin L:=TStringList.Create; try try if not idFTP1.Connected then idFTP1.Connect; repftp := idFTP1.RetrieveCurrentDir; root:=length(dir)=0; if not root then begin if dir='..' then idFTP1.ChangeDirUp else idFTP1.ChangeDir(trim(dir)); end; Combobox1.Clear; Combobox1.Items.Add(idFTP1.RetrieveCurrentDir); combobox1.ItemIndex:=0; root:=(repftp=idFTP1.RetrieveCurrentDir); ColonneTri:=0;ColonneOrdre:=1; ListView1.Items.Clear; idFTP1.List; for i:= 0 to idftp1.DirectoryListing.Count - 1 do if idftp1.DirectoryListing.Items[i].ItemType=ditFile then begin with ListView1.Items.Add do begin Caption:=Idftp1.DirectoryListing.Items[i].FileName; if Idftp1.DirectoryListing.Items[i].SizeAvail then subItems.Add(Format('%15d Ko',[Idftp1.DirectoryListing.Items[i].size])) else subItems.Add(''); subItems.Add(FormatDateTime('dd/mm/yyyy',Idftp1.DirectoryListing.Items[i].ModifiedDate)); subItems.Add(Lowercase(Copy(ExtractFileExt(Idftp1.DirectoryListing.Items[i].FileName),2,9))); end; end else begin if idftp1.DirectoryListing.Items[i].FileName<>'.' then with ListView1.Items.Add do begin if idftp1.DirectoryListing.Items[i].FileName<>'..' then Combobox1.Items.Add(idFTP1.RetrieveCurrentDir+Idftp1.DirectoryListing.Items[i].FileName); Caption:=Idftp1.DirectoryListing.Items[i].FileName; subItems.Add(''); subItems.Add(''); if i>1 then // n'est pas '.' ou '..' peut mieux faire begin subItems.Add('<dir>'); imageIndex:=1; end else begin subItems.Add(''); if root then imageindex:=3 else imageindex:=5; {c'est ici que je voudrait tester l'accessibilité, genre si non accessible alors imageindex=verrou} end; end; end; ColonneOrdre:=-1; ListView1ColumnClick(ListView1,ListView1.Columns[0]); except // if idFTP1.Connected then idFTP1.Disconnect; end; finally L.Free; if idFTP1.Connected then idFTP1.Disconnect; end; end;
Partager