Sur un site , j'ai récupéré un téléchargeur FTP qui fonctionne, mais le problème est qu'il télécharge un fichier, et c'est tout.

Moi, ce que je voudrais c'est qu'il le fasse pour des données que je lui donne (par exemple des bits 11335 à 16416163).

Est-ce possible en FTP ? (Ca l'est en HTTP)

voici le code que j'ai pour le moment :

Déclaration des fonctions :
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
 
boolean ConnexionFTP( char *Serveur, char *Login, char *MotDePasse, DWORD Port )
{
	PConnexionInternet = InternetOpenA(/*L"J-FTP"*/"vfp", INTERNET_OPEN_TYPE_DIRECT,/* NULL, NULL*/0,0, 0 );
	if ( PConnexionInternet == NULL )
	{
		return FALSE;
		ExitProcess(1);
	}
 
	//string s="";
	size_t origsize = 10;//strlen(wcstombs(file).c_str()) + 1;
	size_t convertedChars = 0;
	wchar_t wcstring[100];
	mbstowcs_s(&convertedChars, wcstring, origsize, Serveur/*wcstombs(file).c_str()*/, _TRUNCATE);
	wcscat_s(wcstring, L"");// (wchar_t *)");
	//wstring caption=loadstring(IDS_EXCEPTION);
 
	LPCSTR a=Serveur;
	LPCSTR b=Login;
	LPCSTR c=MotDePasse;
 
	PConnexionFTP = InternetConnectA( PConnexionInternet, (LPCSTR)Serveur, (INTERNET_PORT)Port, (LPCSTR)Login, (LPCSTR)MotDePasse, INTERNET_SERVICE_FTP, 0, 0 );
 
	if ( PConnexionFTP == NULL )
	{
			InternetCloseHandle( PConnexionInternet );
			return FALSE;
			ExitProcess(1);
	}
 
	return TRUE;
 
}
 
boolean changeRepertoire(char* newrep)
{
	return FtpSetCurrentDirectoryA(PConnexionFTP,newrep);
}
 
/* Detruit les pointeurs de connection */
void Deconnexion()
{
	InternetCloseHandle( PConnexionInternet );
 
    InternetCloseHandle( PConnexionFTP );
}
 
/* DownLoad Fichier */
boolean DownLoadFile( char *FichierSurFTP, char *FichierACreer )
{
    return FtpGetFileA( PConnexionFTP, (LPCSTR)FichierSurFTP, (LPCSTR)FichierACreer, FALSE, 0, FTP_TRANSFER_TYPE_BINARY, 0 );
}
 
boolean DownLoadFileText( char *FichierSurFTP, char *FichierACreer )
{
    return FtpGetFileA( PConnexionFTP, (LPCSTR)FichierSurFTP, (LPCSTR)FichierACreer, FALSE, 0, FTP_TRANSFER_TYPE_BINARY, 0 );
}
 
/* Upload Fichier */
void UpLoadFile( char *FichierLocal, char *FichierFTP )
{
    FtpPutFileA( PConnexionFTP, (LPCSTR)FichierLocal, (LPCSTR)FichierFTP, FTP_TRANSFER_TYPE_BINARY, 0 );
}
Utilisation :
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
 
res=acceder(0,hwnd,ftp[i].adresse);
addr=res[0];
login=res[1];
ficsource=res[2];
ficdest=res[2];
affiche(hwnd,"ftp");
if (ConnexionFTP((char*)addr.c_str(), (char*)login.c_str(),(char*)mdp.c_str(), 21 )==TRUE)
{
	affiche(hwnd,"Connection...");
	res=acceder(1,hwnd,ftp[i].adresse); //récupération des données
	if ( Action )  // download
	{
	   affiche(hwnd,"Telecharge");
	   if(!DownLoadFile( (char*)ficsource.c_str(), (char*)ficdest.c_str() ))
	   affiche(hwnd,ficsource);
	}
	else //Upload
	{
	affiche(hwnd,"envoi");
	UpLoadFile( (char*)ficsource.c_str(), (char*)ficdest.c_str() );
	}
	Deconnexion();
	affiche(hwnd,"Deconnection");
	}
	else
	{
	affiche(hwnd,"Deconnection");
	Deconnexion();	
	ExitProcess(1);
	}
}