473,405 Members | 2,415 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

an OpenFileDialog problem

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
Nov 17 '05 #1
2 2349
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"!

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Nov 17 '05 #2
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
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jody Gelowitz | last post by:
VS.NET 2002 and 2003 are installed. ..NET Framework 1.0 and 1.1 installed Program running under VisualBasic.NET 2002 with .NET Framwork 1.0 I am experiencing a problem with ADO.NET where the...
3
by: bobrad | last post by:
MAYBE SOMEBODY CAM HELP I AM USING THE FOLLOWING CODE TO GET A LOCATION OF A FILE IN A WINFORM DIALOG OpenFileDialog openFileDialog = new OpenFileDialog(); OpenFileDialog.Filter = " Access...
4
by: Nagachandra Sekhar Grandhi | last post by:
I am facing a problem with OpenFileDialog. It is as follows. I opened OpenFileDialog dialog box and selected a folder in it. After selecting the folder when i tried to delete the same folder in...
8
by: e-mid | last post by:
why does not openFileDialog have closed event? i want to do something; as soon as the dialog closes. is there a way to do this?
1
by: Johann Blake | last post by:
A number of posts have indicated developers having problem getting an OpenFileDialog to startup in a specific directory when the dialog is shown. The first time you show the dialog, the...
6
by: barbara_dave | last post by:
Hi, All, I want to use the openfiledialog to open different extension files in different directory( only one type files at one time). I set the OpenFiledialog InitialDirectory and Filter...
3
by: juststarter | last post by:
Hello all, I am using an openFileDialog box to select a file (in order to insert it in a database). When the file is selected i am filling a few textboxes with the actual path, filename and...
8
by: marcus.kwok | last post by:
I am having a weird problem and I have can't figure out why it is happening. I create an OpenFileDialog and set a filename filter. When the dialog first opens, the filter works correctly, and...
2
by: MikeY | last post by:
Hi everyone, I"m having a problem with the OpenFileDialog() changing my path to save to my .resources file. I'm a bit baffled why this is happening, even when I set the OpenFileDialog back to...
0
by: mbewers1 | last post by:
Hi I'm having a problem trying to get a customised OpenFileDialog() to fulfil my requirements. The code for this custom-built dialog has been taken from another site...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.