Api fptgetfiles

henneuse_alain Messages postés 5 Date d'inscription vendredi 18 août 2000 Statut Membre Dernière intervention 6 mai 2011 - 7 juil. 2002 à 09:38
henneuse_alain Messages postés 5 Date d'inscription vendredi 18 août 2000 Statut Membre Dernière intervention 6 mai 2011 - 7 juil. 2002 à 10:48
bonjour,
voila mon probléme:
j'ai realisé un petit programme qui telécharge via un serveur ftp un fichier au format txt.Comme le contenu du fichier sur le serveur ftp change souvent,dans mon appli distante j'ai activer un timer(10s) pour mettre a jour le fichier sur mon disque dur,bien que le contenu du fichier sur le serveur soit modifier,je transfert toujour le meme contenu q'a la premiere connection.

que dois je faire pour que le fichier sur mon dique soit le meme que celui du serveur.

1 réponse

henneuse_alain Messages postés 5 Date d'inscription vendredi 18 août 2000 Statut Membre Dernière intervention 6 mai 2011
7 juil. 2002 à 10:48
voici le prog:

Const FTP_TRANSFER_TYPE_UNKNOWN = &H0
Const FTP_TRANSFER_TYPE_ASCII = &H1
Const FTP_TRANSFER_TYPE_BINARY = &H2
Const INTERNET_DEFAULT_FTP_PORT = 21 ' default for FTP servers
Const INTERNET_SERVICE_FTP = 1
Const INTERNET_FLAG_PASSIVE = &H8000000 ' used for FTP connections
Const INTERNET_OPEN_TYPE_PRECONFIG = 0 ' use registry configuration
Const INTERNET_OPEN_TYPE_DIRECT = 1 ' direct to net
Const INTERNET_OPEN_TYPE_PROXY = 3 ' via named proxy
Const INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY = 4 ' prevent using java/script/INS
Const MAX_PATH = 260
Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Private Type WIN32_FIND_DATA
dwFileAttributes As Long
ftCreationTime As FILETIME
ftLastAccessTime As FILETIME
ftLastWriteTime As FILETIME
nFileSizeHigh As Long
nFileSizeLow As Long
dwReserved0 As Long
dwReserved1 As Long
cFileName As String * MAX_PATH
cAlternate As String * 14
End Type
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer
Private Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal hInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Integer, ByVal sUserName As String, ByVal sPassword As String, ByVal lService As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
Private Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" (ByVal hConnect As Long, ByVal lpszRemoteFile As String, ByVal lpszNewFile As String, ByVal fFailIfExists As Long, ByVal dwFlagsAndAttributes As Long, ByVal dwFlags As Long, ByRef dwContext As Long) As Boolean
Const PassiveConnection As Boolean = True

Private Sub Form_Load()
'open an internet connection
hOpen = InternetOpen("API-FTP", INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
'connect to the FTP server
hConnection = InternetConnect(hOpen, "217.136.206.217", INTERNET_DEFAULT_FTP_PORT, "alain", "alain", INTERNET_SERVICE_FTP, IIf(PassiveConnection, INTERNET_FLAG_PASSIVE, 0), 0)
End Sub

Private Sub Form_Unload(Cancel As Integer)
'close the internet connection
InternetCloseHandle hOpen

'close the FTP connection
InternetCloseHandle hConnection
End Sub

Private Sub Timer1_Timer()

'retrieve the file from the FTP server
FtpGetFile hConnection, "alain.txt", "c:\ftp.txt", False, 0, FTP_TRANSFER_TYPE_ASCII, 0

Open "c:\ftp.txt" For Input As #1
Line Input #1, Data
Print Data
Close #1

End Sub
---------------------------
module
Global hConnection As Long, hOpen As Long, sOrgPath As String
0
Rejoignez-nous