cannot convert from 'System::String ^' to 'char *'Here comes to scene marshalling. In namespace System.Runtime.InteropServices you can find the class Marshal. You simply add reference to you C++ project.
using namespace System::Runtime::InteropServices;Then you just get pointer to your parameter using Marshal::StringToHGlobalAnsi. Use static_cast operator to convert the pointer to char* type.
void Adapter::SetSavePath(String^ path) { IntPtr p = Marshal::StringToHGlobalAnsi(path); char* newCharStr = static_cast<char*>(p.ToPointer()); }Then you just call your method in C#.
private void saveAsButton_Click(object sender, EventArgs e) { FolderBrowserDialog fbd = new FolderBrowserDialog(); if (fbd.ShowDialog() != DialogResult.Cancel) { if (fbd.SelectedPath != null) { string savePath = fbd.SelectedPath; adapter.SetSavePath(savePath); //adapter is instance of Adapter } } }Easy right? I wish I knew two months ago... It costs me a lot of hair :))
D.Š.