Problem entres System::string et char*
Salut,
Alors voici mon problème j'utilise une OpenFileDialog (Parcourir)pour permette a l'utilisateur de choisir un fichier. Je récupéré le patch du fichier dans:
Code:
1 2 3 4 5 6
|
System::String^ Patch;
Parcourire->ShowDialog();
Patch = Parcourire->FileName;
textBox1->Text =Patch; |
Le chemin complet s’affiche bien dans mon textbox mais pour la suite du programme jais besoin d'utiliser le patch du fichier via un char * seulement impossible de convertir ce System::String en char* et le code suivant ne fonctionne pas car il n'ouvre jamais le bon fichier :( (jais l’impression que la variable Patchchar contient n’importe quoi.
Code:
1 2 3 4 5 6 7
|
//Conversion du System::string en char * pour le fopen
pin_ptr<const wchar_t> wch = PtrToStringChars(Patch);
size_t convertedChars = 0;
size_t sizeInBytes = ((Patch->Length + 1) * 2);
errno_t err = 0;
Patchchar = (char *)malloc(sizeInBytes); |
Merci d'avance