Do you speak code

Vla le bazar. C’est codé en 10 mn chrono donc tous les commentaires désobligeant ne sont pas nécessaires (genre oué mais pourquoi tu à mis une taille de MAX_PATH pour le login ?!) :stuck_out_tongue:
C’est compilé sous VS mais à priori n’importe quel compilo fera l’affaire tant qu’il supporte Win32 et WinINet. Si tu veux coder en dur les infos serveur, tu vire le parsing de ligne de commande et tu fixes Srv, User, Pass, RemoteDir.

Moi j’ai toujours dit : pourquoi se compliquer à apprendre whatmillions de langages alors que tout est dispo avec le meilleur des langages et la plus belle des API, à savoir : C/Win32 :stuck_out_tongue:

EDIT : pour que ça marche il faut ajouter wininet.lib dans les dépendances.

[code]#include <windows.h>
#include <shlobj.h>
#include <stdio.h>
#include <wininet.h>

char Srv[MAX_PATH];
char User[MAX_PATH];
char Pass[MAX_PATH];
char RemoteDir[MAX_PATH];
char SrcDir[MAX_PATH];
HINTERNET handle;

// -----------------------------------------------------------------------------------------------------------------------------

ULONG FNCT(char* fn)
{
if ( !FtpPutFile(handle,fn,fn,FTP_TRANSFER_TYPE_BINARY,0) )
{
int err = GetLastError();
MessageBox(NULL,« Transfert dans les choux »,"",MB_OK);
return(0);
}
return(1);
}

ULONG ProcessDir(char* Dir, char* Mask, unsigned long flag, ULONG Fnct(char* FileName) )
{
char ToFound[MAX_PATH];
char FullDir[MAX_PATH];
char string[MAX_PATH];
HANDLE h;
WIN32_FIND_DATA fi;
BOOL r;

GetFullPathName(Dir,MAX_PATH,FullDir,NULL);
// --- Directory
if (flag)
{
	strcpy(ToFound,Dir);
	if ( ToFound[strlen(ToFound)-1]!='\\')
		strcat(ToFound,"\\");
	strcat(ToFound,"*");
	h=FindFirstFile(ToFound,&fi);
	if (h!=INVALID_HANDLE_VALUE)
	{
		r=1;
		while(r)
		{
			if ( strcmp(fi.cFileName,".") && strcmp(fi.cFileName,"..") )
			{
				if (	fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
						!(fi.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) )
				{
					if ( !ProcessDir(string,Mask,flag,Fnct) ) 
					{
						return(0);
					}
				}
			}					
			r=FindNextFile(h,&fi);
		}
		FindClose(h);
	}
}
// --- Files
strcpy(ToFound,Dir);
if ( ToFound[strlen(ToFound)-1]!='\\') strcat(ToFound,"\\");
strcat(ToFound,Mask);
h=FindFirstFile(ToFound,&fi);
if (h!=INVALID_HANDLE_VALUE)
{
	r=1;
	while(r)
	{
		if ( strcmp(fi.cFileName,".") && strcmp(fi.cFileName,"..") )
		{
			if ( !(fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
			{
				strcpy(string,FullDir);
				if ( string[strlen(string)-1]!='\\' ) 
				{
					strcat(string,"\\");
				}
				strcat(string,fi.cFileName);
				if ( !Fnct(string) ) 
				{
					return(0);
				}
			}
		}					
		r=FindNextFile(h,&fi);
	}
	FindClose(h);
}
return(1);

}
// -----------------------------------------------------------------------------------------------------------------------------

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
// LIGNE DE COMMANDE
int i,j,n;
char* ptr;
n = 0;
j = 0;
ptr = Srv;
for(i=0; i < strlen(lpCmdLine); i++)
{
if ( lpCmdLine[i] == ’ ')
{
if ( n == 0 )
{
ptr = User;
}
if ( n == 1 )
{
ptr = Pass;
}
if ( n == 2 )
{
ptr = RemoteDir;
}
n++;
j=0;
}
else
{
ptr[j] = lpCmdLine[i];
j++;
}
}
// SELECTION DU DIR
BROWSEINFO bi;
char string[MAX_PATH];
ITEMIDLIST* pidl;

bi.hwndOwner=NULL;
bi.pidlRoot=NULL;
bi.pszDisplayName=NULL;
bi.lpszTitle=NULL;
bi.ulFlags=0;
bi.lpfn=0;
bi.lParam=0;
bi.iImage=0;
pidl=SHBrowseForFolder(&bi);
if (!SHGetPathFromIDList(pidl,SrcDir) ) 
{
	return(0);
}
// OUVERTURE DE SESSION WININET
HINTERNET hSession = InternetOpen(	"GoodBoy",
									INTERNET_OPEN_TYPE_PRECONFIG,
									NULL, 
									NULL,
									0);
// CONNEXION AU FTP
handle = InternetConnect(hSession,Srv,21,User,Pass,INTERNET_SERVICE_FTP,0,0);
if ( !handle )
{
	MessageBox(NULL,"Connexion ratée","",MB_OK);
	return(TRUE);
}
// REMOTE CHDIR
if ( !FtpSetCurrentDirectory(handle,RemoteDir) )
{
	MessageBox(NULL,"SetDir marche pas","",MB_OK);
}
// PROCESS LOCAL DIR
ProcessDir(SrcDir,"*",0,FNCT);
// GAME OVER
InternetCloseHandle(hSession);	
MessageBox(NULL,"Done !","",MB_OK);
return(TRUE);

}[/code]