Bonjour,
Malgré des recherches sur les forums, je n'ai pas trouvé de réponse à mon souci.
J'ai chargé Synapse qui me permet de télécharger un fichier distant avec ftpsend.
J'ai essayé d'y ajouter une barre de progression mais les exemples que j'ai pu trouver ça et là me donnent trop souvent des erreurs d'incompatibilé ou ce composant absent avecEst-ce que quelqu'un aurait un lien vers quelque chose qui pourrait m'aider ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part FTPClient := TFTPSend.Create et FileStream := TFileStream.Create(LocalFileName, fmCreate);
Fonction qui marche :
Merci
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 function DownloadFileFromFTP(RemoteName, LocalFileName: string): Boolean; var //'ftp://dyia_bta_alpin@ftp.agilsport.fr/EET_Calculator_install_1.1.0.exe'; strFTPHost: String; strFTPuser: String; strFTPpw: String; LocalFile: String; FTPClient : TFTPSend; RemoteDir: String; RemoteFile: String; rc: boolean; size: Integer ; begin strFTPHost:= 'ftp.xxxt.fr'; strFTPuser:= 'yyy'; strFTPpw:= '*******'; LocalFile:= LocalFileName; //RemoteFile:= RemoteName; RemoteFile:= 'EET_Calculator_install_1.1.0.exe'; FTPClient := TFTPSend.Create; with FTPClient do begin try TargetPort := '21'; TargetHost := strFtpHost; UserName := strFTPuser; Password := strFTPpw; //---------------------------------- // bail out if the FTP connect fails if not LogIn then begin ShowMessage('Erreur / FTP login'); exit; end; size := FileSize(RemoteFile); ShowMessage(IntToStr(size)); // Set filename to FTP DirectFileName := LocalFileName; DirectFile := True; // change directory if requested if RemoteDir <> '' then ChangeWorkingDir(RemoteDir); // STOR file to FTP server. // rc := StoreFile(RemoteFile,false); // RETR file from FTP server. rc := RetrieveFile(RemoteFile, False); // close the connection LogOut; Except On E: Exception do begin ShowMessage('Error: ' + E.Message ); end; end; // free the FTP client object free; end; end;
Philippe
Partager