Vérifier qu'un fichier existe (System::String* To Char*)
Voila j'ai besoin de voir si un fichier est valide... Pour cela, je récupère le pathName (qui vient de mon form) sous form de System::String*.
Pour vérifier la validié, j'écit une petite fonction :
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| if((_access(file, 0)) != -1 )
{
if(showDialogBox)
MessageBox(NULL, "Existe", "About", MB_OK);
// Pour permission décriture
if( (_access(file, 2)) != -1 )
{
if(showDialogBox)
MessageBox(NULL, "OK for writing", "About", MB_OK);
return true;
}
} |
(il y a un else etc...)
On voit ici que _access a besoin de la variable "file" qui, pour cette fonction, doit être un char*.
Pour passer de String* à char* j'ai pas trop mal cherché et j'ai trouver ceci :
Code:
Char file[] = s_file->ToCharArray();
où file_S est le System::String*.
Ca ne marche pas... Le compilo me renvoit :
Citation:
error C2664: '_access' : cannot convert parameter 1 from '__wchar_t __gc[]' to 'const char *'
Quelqun aurait*il une idée pour m'aider ?
Merci de votre aide.
Col.