System::String^ to char *

Is there a way to convert a System::String^ to char *? I am trying to use label->Text to open a file for writing &/or reading. So far I have not been able to discover a way to do that. I consistently get a C2440 error message. Would someone point me in the right direction.
Thanks,
Dave
1
2
3
4
5
6
7
8
9
10
11
#include <msclr\marshal_cppstd.h>
#include <string>

using namespace System;

String^ name = "Anna";

std::string anna = msclr::interop::marshal_as<std::string>(name);

//do sth with anna.c_str(); 
    


BTW. Why don't you use the .NET classes (like System::IO::File) to read or write to files.
Thanks for the replies. I think I got it working now. Dave
Topic archived. No new replies allowed.