Hello all
I have a problem.I am trying to convert 'System:tring ^' to 'const char *' but i don`t know how.
can some one please help me?

I use VC++ 2005
I need to open files with extension .wav

my code is:

public:System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) 
 OpenFileDialog open;
open.Title = "Select Wave File";
open.Multiselect = true;
open.CheckFileExists = true;
open.Filter = "Audio Files (*.wav)|*.wav";
open.FilterIndex = 2;

if (open.ShowDialog()==System::Windows::Forms::DialogResult::OK )

ifstream waveFile (open.FileName);// my error is here

if I use for example
ifstream waveFile("test.wav") i get no errors

what can I do if I want to open *.wav

Does system::string have anything in common with std::string ?

In which case, perhaps it has a method like this.

ifstream waveFile ( open.FileName.c_str() );

You can use one of the Marshal::StringToHGlobalAnsi/Auto/Uni methods to copy the string into unmanaged memory, and then clean up with Marshal::FreeHGlobal when you're done.

There's an example here that does exactly that.

Thank you +rep
This question has already been answered. Start a new discussion instead.