Feb 4, 2015 at 2:24am UTC
I have a form with a label.
I use the openfile dialog to get a filename and save it to the labeltext.
I then need to get the label text and build a new filename from it.
int rtn;
string oldname;
OpenFileDialog^ sfd = gcnew OpenFileDialog();
sfd->Filter = "Pose Files|*.pz2|All files (*.*)|*.*";
if( sfd->ShowDialog() != System::Windows::Forms::DialogResult::OK )
{
return;
}
myfile->Text = sfd->FileName;
oldname = myfile->Text;
}
This gives me a build error.
In the old c++ 6 I used Cstring for the variable oldname but it seems to be unavailable in VS 2010.
any help appreciated.
Feb 4, 2015 at 9:10am UTC
1) This is not C++. This is C++/CLI which is a different language.
2) Without the error you are getting and such small snippet of code, not many people will be able to help.
3) Standard C++ classes and managed CLI stuff are not getting along. Try System::String instead of std::string.
Feb 4, 2015 at 4:03pm UTC
OK, thanks
I did the program originally in Microsoft Visual studio 6 using C++
This version is using Visual Studio Express 2010 - the C++ from it.
I added #include<string>
what do I include for the system::string instead ?
Feb 4, 2015 at 4:38pm UTC
This version is using Visual Studio Express 2010 - the C++ from it.
But what you've posted still is not c++.
yep that's the one. then you can instantiate like this:
std::string myString("hello" );
BUT that's assuming you'll be switching to pure c++. otherwise miniipaa's number 3.
Last edited on Feb 4, 2015 at 4:39pm UTC