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
|
/*Maj : 24/08/2007 Test FTP*/
/*Ne fonctionne que sous Windows !!*/
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <Wininet.h>
int main(void)
{
HINTERNET hsession, hftp;
hsession = InternetOpen ("ftp", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
if(hsession == NULL)
{
printf("*****ERROR*****\n" );
return 1;
}
hftp = InternetConnect(hsession, "ftpperso.free.fr", INTERNET_DEFAULT_FTP_PORT, "login", "mdp", INTERNET_SERVICE_FTP, 0, 0);
if(hftp)
{
/*Envoie de fichier*/
/*FtpPutFile(hftp,"atom1.tar.gz"/*fichier recherché*/, "atom1.tar.gz"/*fichier créé*/, FTP_TRANSFER_TYPE_BINARY, 0);*/
/*Reception de fichier*/
FtpGetFile(hftp, "atom1.tar.gz", "atom1.tar.gz",1/*Gère si fichier exist*/,FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_BINARY, 0);
InternetCloseHandle(hftp);
}
else printf("******ERROR*******\n" );
InternetCloseHandle(hsession);
system("pause" );
return 0;
} |
Partager