voila mon petit bout de code qui copie tous les fichiers d'un repertoire(c:\t) vers un autre repertoire (c:\Zipper_Vtfw32) temporaire mais j'ai des erreurs lorsqu'il s'agit de fichier qui ne sont pas d'extension txt ou bin... si quelqu'un a une idee pour modifier cette fonction merci d'avance :)
void CTestDlg::OnOK()
{
// TODO: Add extra validation here
MyCopyDirectoryRec("c:\\t");
CDialog::OnOK();
}
void MyCopyDirectoryRec(CString rep)
{
char NewFileNameDebug[]={"c:\\Zipper_Vtfw32\\"};
char FileNameDebug[MAX_PATH];
BOOL bErr = false;
unsigned int cpt = 0;
WIN32_FIND_DATA FindFileData;
strcpy(FileNameDebug,rep);
strcat(FileNameDebug,"\\*.*");
HANDLE hFind = FindFirstFile(FileNameDebug, &FindFileData);
if (hFind==INVALID_HANDLE_VALUE)
return;
DWORD a = 0;
while (cpt<5)//(a != ERROR_NO_MORE_FILES)
{
try
{
FindNextFile(hFind, &FindFileData);
}
catch( DWORD a )
{
a = GetLastError();
bErr = true;
}//end catch
if (bErr == false)
{
if (strcmp(FindFileData.cFileName,".")!=0)
{
strcpy(FileNameDebug,rep);
strcat(FileNameDebug,"\\");
strcat(FileNameDebug,FindFileData.cFileName);
char NewFileNameDebug[] ={"c:\\Zipper_Vtfw32\\"};
strcat(NewFileNameDebug,FindFileData.cFileName);
CopyFile(FileNameDebug,NewFileNameDebug,0);
}
}
if(a == ERROR_NO_MORE_FILES)
break;
cpt++;
}
FindClose(hFind);
}