Hello
I am trying to open a text file, I use this code :
private: void button1_Click(System::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() == ::DialogResult::OK )
{
if ( (myStream = openFileDialog1->OpenFile()) != nullptr )
{
myStream->Close();
}
}
}
The problem is that I obtain this error messages :
error C3083: 'DialogResult': the symbol to the left of a '::' must be a type
error C2039: 'OK' : is not a member of '`global namespace''
error C2065: 'OK' : undeclared identifier
All the errors are in this line :
if ( openFileDialog1->ShowDialog() == ::DialogResult::OK )
Please help me
Thanks
Jochen Kalmbach [MVP] - 26 May 2005 20:28 GMT
Hi tlemcenvisit!
> All the errors are in this line :
>
> if ( openFileDialog1->ShowDialog() == ::DialogResult::OK )
If a symbols starts with "::" it is assumed that it is in the
global-namespace!
So please remove the "::" at the beginning of the "DialogResult::OK"!

Signature
Greetings
Jochen
My blog about Win32 and .NET
http://blog.kalmbachnet.de/
tlemcenvisit - 26 May 2005 21:05 GMT
I have doing it
Now I have two error messages:
e:\projets visual studio\rien\rien\Form1.h(121) : error C2039: 'OK' : is not
a member of 'System::Windows::Forms::Form::DialogResult'
e:\projets visual studio\rien\rien\Form1.h(24) : see declaration of
'System::Windows::Forms::Form::DialogResult'
e:\projets visual studio\rien\rien\Form1.h(121) : error C2065: 'OK' :
undeclared identifier
Please help me