|
-
February 15th, 2010, 03:14 AM
#1
Open File Dialog
Hello i am making a simple program in visual c++, i have it so that when i hit a button the Open File dialog pops up. But when i open something i want it to return the file name of what i opened so that my program my deal with it.
Here is my attempt
Code:
string account2;
account2 = openFileDialog1->FileName;
The error i receive.
binary '=' : no operator found which takes a right-hand operand of type 'System::String ^' (or there is no acceptable conversion)
Can someone please step me in the right direction? Many Thanks - marsh
-
February 15th, 2010, 08:04 AM
#2
Re: Open File Dialog
This works quite fine, try it
String^ account2;
account2=openFileDialog1->FileName;
THANX
-
February 15th, 2010, 08:07 AM
#3
Re: Open File Dialog
It seems your example is for Visual basic of C++.
Visual C++
private:
void button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
Stream^ myStream;
OpenFileDialog^ openFileDialog1 = gcnew OpenFileDialog;
openFileDialog1->InitialDirectory = "c:\\";
openFileDialog1->Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
openFileDialog1->FilterIndex = 2;
openFileDialog1->RestoreDirectory = true;
if ( openFileDialog1->ShowDialog() == System::Windows::Forms:  ialogResult::OK )
{
if ( (myStream = openFileDialog1->OpenFile()) != nullptr )
{
// Insert code to read the stream here.
myStream->Close();
}
}
}
(Source: http://msdn.microsoft.com/en-us/libr...iledialog.aspx)
-
February 15th, 2010, 12:53 PM
#4
Re: Open File Dialog
Thank you i got it working.
-
February 15th, 2010, 04:54 PM
#5
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|